Exercise: Build a Greeting With F-Strings
Bartosz Zaczyński RP Team on Sept. 20, 2026
Hi @Guy I. Horn, the main thing is that the f prefix belongs to the string, not to the function name. Right now build_greetingF"..." puts the F at the end of the name, so Python sees a name followed by a string and raises a SyntaxError.
Using a capital F is fine, by the way (the lesson mentions that at 0:54). It just needs to sit right before the opening quote.
The exercise also asks you to write a function, so you need def and a return:
def build_greeting(name, age):
return f"Hello, {name}. You are {age}."
Since name and age come in as parameters, you don’t need to assign them at the top. You pass them in when you call the function:
>>> build_greeting("Eric", 74)
'Hello, Eric. You are 74.'
One small detail to match the expected output: there’s a period after the name, not a comma. So Hello, {name}. You are {age}.
The Simple Syntax of F-Strings lesson walks through the prefix and curly brace syntax if you want a quick refresher 🙂
Become a Member to join the conversation.
Guy I. Horn on Sept. 16, 2026
Hello, this is Guy, I seem to be stuck on how to input a function with an f-string. I’m not sure what I did wrong:
Help, thanks.