Strip Leading Spaces in Python

Level 122 keystrokes

This removes leading whitespace from a string using lstrip().

Python code

# lstrip() returns a copy with leading (left-side) whitespace removed
# The two spaces before "hi" are dropped, so hi is printed
1print(" hi".lstrip())

Output

hi
Practice typing this code

Practice typing this code. Results are not recorded in the rankings.

Symbols in this code

The symbols you type in this Python code and how often they appear.

  • "× 2
  • (× 2
  • )× 2
  • .× 1

More Python examples at level 1

← Python typing practice