✅ The expected output of the code down below should be this:
Hello, my name is Alice and I am 30 years old.
❌ However, the code outputs this instead:
Hello, my name is {name} and I am {age} years old.
What is the problem? Drop your answer in the comments.
def main():
name = "Alice"
age = 30
# Intentional error: Using a wrong variable name inside the f-string
message = "Hello, my name is {name} and I am {age} years old."
print(message)
if __name__ == "__main__":
main()
Just missing the f key in the beginning of the message.
message = f"Hello, my name is {name} and I am {age} years old."