0

Let's say I have this function

def family():
    S = dict(eyes='hazel', hair='ash')
    N = dict(eyes='blue', hair='blonde')
    K = dict(eyes='brown', hair='ash')
    print()
family()

How do I make the function print based on the argument in the parentheses? for example if i enter family(S)

I want the S dictionary to print and so forth. How would I do this? Thanks

Paolo
  • 21,270
  • 6
  • 38
  • 69
  • The question title, makes me think that this would be a more appropriate answer: https://stackoverflow.com/a/2521937/6282058 – Armin Apr 13 '20 at 11:34
  • i dont understand what that is doing – Henrietta Shalansky Apr 13 '20 at 11:39
  • `locals()` returns a dictionary mapping function argument names to their values. From your question, it wasn't clear whether you would like to print function arguments and values as a dictionary (e.g. `def family(eyes, hair) ...` and `family(eyes='hazel', hair='ash') -> {'eyes': 'hazel', 'hair': 'ash'}` – Armin Apr 13 '20 at 11:54

0 Answers0