Python is new to me. I'm on the chapter of Function now.
Here's my code - Just concerned about why I am unable to use the input feature in this case:
def build_profile (first_name, last_name, **personal_traits):
profile = {}
profile ['First name'] = first_name
profile ['Last name'] = last_name
for key,value in personal_traits.items():
profile[key]=value
return profile
fn = input("What's your first name? ").title()
ln = input("What's your last name? ").title()
ptr = input('What are your personal traits? name three ').title()
your_info = build_profile(fn,ln,ptr)
print(your_info)
Error
What's your first name? liwei
What's your last name? hsu
What are your personal traits? name three x,y,z
Traceback (most recent call last):
File "/Users/liwei/PycharmProjects/pythonProject/ReviewLession/For Whatever Practice Use.py", line 14, in <module>
your_info = build_profile(fn,ln,ptr)
TypeError: build_profile() takes 2 positional arguments but 3 were given
I've tried It worked perfectly fine by taking away the input section, which I understood.
I tried adding ** onto this part:
your_info = build_profile(fn,ln,**ptr)
print(your_info)
- but it didn't work! Not entirely sure how to solve this if insisted on using input function.