I'm trying to implement a function with 2 arguments and an additional 3rd arbitrary keyword argument using **kwarg
formatting, as below:
def build_profile(first_name, last_name, **additional_info):
""" Building a user profile """
profile = {}
profile['First name'] = first_name
profile['Last name'] = last_name
for key, value in additional_info.items():
profile[key.title()] = value.title()
return profile
build_profile("x", 'y', 'x', 'y', 'x', 'y')
However, this produces the error:
TypeError: build_profile() takes 2 positional arguments but 6 were given
I managed to reproduce this error in isolation using the following code:
def x(**y):
print(y)
Output:
x(1,2,3,4,5)
This generates the same response:
TypeError: x() takes 0 positional arguments but 1 was given
This has lead me to conclude that I either:
- Have an issue with my python configuration (running 3.6.4 in Spyder) or
- I'm missing something blindingly obvious.