С вашим форматированием сложно сказать что у вас происходит.
Но код 100% рабочий
def get_formatted_name(first_name, last_name):
"""Return a full name, neatly formatted."""
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}!")
Output:
Please tell me your name:
(enter 'q' at any time to quit)
First name: Boris
Last name: Rad
Hello, Boris Rad!
Please tell me your name:
(enter 'q' at any time to quit)
First name: q
Вероятно, вы не добавили отступы для последних двух строк:
formatted_name = get_formatted_name(f_name, l_name)
print(f"\nHello, {formatted_name}!")