I defined this function:
def formatted_name(firstName, lastName, middleName=''):
if middleName:
full_name = f"{firstName} {lastName} {middleName}"
else:
full_name = f"{firstName} {lastName}"
return full_name.title()
and then tried to use it like so:
prompt = 'Please enter your first and last name below'
prompt += '\nEnter stop to quit'
quit = 'stop'
while not quit:
print(prompt)
firstname = input('Enter your first name: ')
lastname = input('Enter your last name: ')
if firstname == quit:
break
fullName = formatted_name(firstname,lastname)
print(fullName)
When I try this, I get a NameError
. What is wrong with the code, and how do I fix it?