Say Hello with an f-string π
Often you want to put a value inside a sentence. Python has a neat tool for
that: the f-string. Put an f before the opening quote, then wrap any value
in {curly braces}:
name = "Sam"
f"Hello, {name}!" # "Hello, Sam!"
Python swaps {name} for the value inside it. Everything else stays as plain
text.
Your task
Write greet(name) that returns "Hello, <name>!" β for example
greet("Sam") returns "Hello, Sam!".
β‘ 25 XP
π§± Code blocks
Drag a block into the editor, or tap it to drop it in where your cursor is. Add them in order to build your answer.
solution.pyRuns in your browser (Pyodide)
Loading editorβ¦
Tests2 to pass
greet("Sam") == "Hello, Sam!"
greet("Ada") == "Hello, Ada!"
Run your code to check these.