String Expandtabs in Python

Level 258 keystrokes

This expands tab characters to spaces with a tab size of 4.

Python code

# Create a string with tab characters (\t) between the letters
1text = "a\tb\tc"
# expandtabs(4) replaces each tab with spaces up to the next multiple of 4
# After the 1-character "a", 3 spaces reach column 4
2result = text.expandtabs(4)
# Prints a, b and c separated by 3 spaces each
3print(result)

Output

a   b   c
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
  • \× 2
  • =× 2
  • .× 1

More Python examples at level 2

← Python typing practice