Answer the question
In order to leave comments, you need to log in
How to pass a dictionary name to a function?
Good afternoon. There was a problem with kwargs in Python, I searched the Internet, but did not find the answer. When calling the function, python gives an error that it expects 0 arguments, and 1 is passed. If I pass the dictionary itself instead of the name of the dictionary, then there are no errors, but I would like to pass exactly the name of the dictionary. Explain what is wrong. Thanks in advance :)
people = {
'josh': 'man',
'jack': 'man',
'anna': 'woman'
}
def people(**kwargs):
for name, sex in kwargs.items():
print(name + ' is a ' + sex)
people(people)
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question