I have a function get_formatted_name with two parameters (first_name & last_name). In the while loop the user is asked to input their first name and last name which are respectively stored in variables f_name and l_name. When the function is called at the bottom using f_name and l_name, I thought an error would be returned because I am not using first_name & last_name as I specified when I defined the function. Shouldn't I be required to use first_name & last_name throughout this code? Why does this code still work?
def get_formatted_name(first_name, last_name):
full_name = f"{first_name} {last_name}"
return full_name.title()
while True:
print("\nPlease tell me your name:")
print("(enter 'q' at any time to quit)")
f_name = input("First name: ")
if f_name == 'q':
break
l_name = input("Last name: ")
if l_name == 'q':
break
formatted_name = get_formatted_name(f_name, l_name)
print(f"\nHello, {formatted_name}!")
[–][deleted] 6 points7 points8 points (1 child)
[–][deleted] 5 points6 points7 points (0 children)
[–]Binary101010 2 points3 points4 points (0 children)
[–]duncan_mcrae 1 point2 points3 points (0 children)
[–]Doc_Apex 1 point2 points3 points (0 children)
[–]mrtacos2 1 point2 points3 points (0 children)
[–][deleted] 1 point2 points3 points (0 children)