Functions · Python exercise
Write a function that returns a formatted greeting.
Define a function named greet that accepts a name and returns Hello, name! with the name stripped of surrounding whitespace. Read one line, call the function, and print the result.
Example 1
Input
Ada
Output
Hello, Ada!
Example 2
Input
Grace
Output
Hello, Grace!
How testing works
Your code runs once per test case with that case's standard input. Output is compared after normalising trailing spaces and blank lines at the end. Use input() without a prompt when the exercise expects clean output.
Loading editor…
Press Run tests to execute your code against every input case. Python runs in a Web Worker in your browser.