your function expects only positional arguments and you try to pass keyword arguments it doesn't expect, thus the error. If you pass keyword arguments they need to be present in the function signature. However if keyword arguments present in the function signature you can [almost ever] pass them also as positional arguments (it's possible to force that function take only positional or only keyword arguments). e.g.
def greet(name='John', familly='Doe'):
print(f'Hello, {name} {familly}')
user = {'name': 'Harry', 'familly': 'Potter'}
greet(**user)
greet(name='Hermione', familly='Granger')
greet('Ron', 'Weasley')
greet()
Output:
Hello, Harry Potter
Hello, Hermione Granger
Hello, Ron Weasley
Hello, John Doe
In addition, your use case does not really warrant use of multiple keyword arguments. Do you really want to have close to 200 arguments? It would be better to pass the dict as single argument
def print_capitals(capitals=None):
if capitals:
for country, capital in capitals.items():
print(f'Capital of {country} is {capital}')
else:
print("Youd didn't supply capitals")
my_dict = {'USA':'Washington','France':'Paris','China':'Beijing'}
print_capitals()
print_capitals(capitals=my_dict)
Output:
Youd didn't supply capitals
Capital of USA is Washington
Capital of France is Paris
Capital of China is Beijing
Now, there is a way to take arbitrary number of positional and keyword arguments.
def some_func(*args, **kwargs):
print(f'Positional arguments: {args}')
print(f'Keyword arguments: {kwargs}')
print('--------------\n')
pos = {'foo', 'bar'}
keyw = {'spam':1, 'eggs':2}
some_func('foo', spam=1)
some_func('foo', 'bar', spam=1, eggs=2)
some_func(*pos)
some_func(**keyw)
some_func('foo', **keyw)
some_func(*pos, **keyw)
Output:
Positional arguments: ('foo',)
Keyword arguments: {'spam': 1}
--------------
Positional arguments: ('foo', 'bar')
Keyword arguments: {'spam': 1, 'eggs': 2}
--------------
Positional arguments: ('foo', 'bar')
Keyword arguments: {}
--------------
Positional arguments: ()
Keyword arguments: {'spam': 1, 'eggs': 2}
--------------
Positional arguments: ('foo',)
Keyword arguments: {'spam': 1, 'eggs': 2}
--------------
Positional arguments: ('foo', 'bar')
Keyword arguments: {'spam': 1, 'eggs': 2}
--------------
Note,
args
and
kwargs
are just names used by convention, they can be different