0

Hi and thanks in advance for any help.

Here is the code that works with the proper output.

first_name="ada"
last_name="lovelace"
full_name=f"{first_name} {last_name}"
message=(f"Hello, {full_name.title()}!")
print(message)

Here is the similar code with no output...and I can't figure out why?

first_name="ada"
last_name="lovelace"
full_name=f"{first_name} {last_name}"
print(full_name)

I know it is correct coding based on the teacher's response but can't figure out why?

Thank you for any help!

4

1 回答 1

0

You forgot to add .title() to your string formatting request.

You can do either:

# to get both capitalized add .title() twice here at "full name".

first_name="ada"
last_name="lovelace"
full_name=f"{first_name.title()} {last_name.title()}"   
print(full_name)

or:


# to get both capitalized add .title() once here at "message".

first_name="ada"
last_name="lovelace"
full_name=f"{first_name} {last_name}"
message=(f"{full_name.title()}")
print(message)
于 2019-11-21T08:58:43.603 回答