Aug-19-2019, 09:29 AM
Hi, i have an example project where i try to pass a dictionary as "**kwargs" to a method. Unfortunately this does not work and i dont know why.
Here is my example-Code:
By executing this script, i get the following error:
Traceback (most recent call last):
File "main.py", line 17, in <module>
myMethod(_MyDict)
TypeError: myMethod() takes 0 positional arguments but 1 was given
...Program finished with exit code 1
Press ENTER to exit console.
Thanks for Help
Here is my example-Code:
1 2 3 4 5 6 7 8 9 |
_MyDict = { "age" : "25" , "name" : "Frank" } def myMethod( * * kwargs): Name = kwargs.pop( 'Name' , 'InitialName' ) Age = kwargs.pop( 'Age' , 'InitialAge' ) print ( "Name:" + Name) print ( "Age:" + Age) myMethod(_MyDict) |
Traceback (most recent call last):
File "main.py", line 17, in <module>
myMethod(_MyDict)
TypeError: myMethod() takes 0 positional arguments but 1 was given
...Program finished with exit code 1
Press ENTER to exit console.
Thanks for Help