Use the Input π₯
So far shout handed back the same word every time. Now we'll let a function
take a value in.
The word inside the parentheses is a parameter β a box that gets filled with
whatever we hand the function. Here name could be anything:
def echo(name):
return name # hand back whatever was passed in
echo("Sam") # "Sam"
echo("Ada") # "Ada"
Notice we return name β no quotes. Quotes would hand back the literal word
"name"; without quotes, Python swaps in the value that was passed.
Your task
Write echo(name) that simply hands back the name it was given.
β‘ 20 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
echo("Sam") == "Sam"
echo("Ada") == "Ada"
Run your code to check these.