Back
+10 XP
Concept

Cleaning Text (.strip())

Humans accidentally type leading and trailing spaces into forms. Scrub them with `.strip()`:

python
email = "   neo@matrix.org \n"
print(email.strip())  # "neo@matrix.org"

# 36. Cleaning Text (.strip()) Humans accidentally type leading and trailing spaces into forms. Scrub them with `.strip()`: ```python email = " neo@matrix.org \n" print(email.strip()) # "neo@matrix.org" ``` `.strip()` cleans whitespace from both ends. `.lstrip()` cleans only the left; `.rstrip()` cleans only the right.

Checkpoint

What does `" admin ".strip()` return?

Practice

You have `input_code = " secret_key "`. Strip the messy edges and print it.

Terminal
01
Tap code blocks below to assemble
Available Blocks