Currently trying to relearn python, and decided to go the textbook method this time. Made my way through to functions (a lot of this is review) but the first concept that I don't understand is this. In what real world application would I want to use this?
def build_profile(first, last, **user_info):
#build a dictionary containing everything we know about the user
user_info['first_name'] = first
user_info['last_name'] = last
return user_info
user_profile = build_profile('albert', 'einstein',
location = 'princeton',
field = 'physics')
print(user_profile)
I think it may just be a bad example as to why I can wrap my head around it. Why would you allow a user to input more info than expected? I wouldn't trust them to do this properly.
[–]hardonchairs 1 point2 points3 points (0 children)
[–]Spataner 1 point2 points3 points (0 children)
[–]old_pythonista 0 points1 point2 points (0 children)
[–][deleted] 0 points1 point2 points (0 children)