Skip to main content
🐍 Python Basics 🐍

Tidy Up Text 🧹

Text often arrives with messy spaces around it. .strip() trims the spaces off both ends:

"  hi  ".strip()   # "hi"

The cool part: you can chain methods one after another, left to right. Each one works on the result of the last:

"  hi  ".strip().upper()   # first "hi", then "HI"

Your task

Write tidy_shout(text) that strips the spaces, makes it UPPERCASE, and adds a "!". tidy_shout(" hi ") returns "HI!".

⚑ 35 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
tidy_shout(" hi ") == "HI!"
tidy_shout("go") == "GO!"

Run your code to check these.