String Repeat in Python

Level 115 keystrokes

This prints 'Ha' repeated 3 times. The * operator with strings repeats the string the specified number of times.

Python code

# With a string and an integer, * repeats the string that many times
# "Ha" * 3 joins three copies into "HaHaHa"
1print("Ha" * 3)

Output

HaHaHa
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
  • (× 1
  • )× 1
  • *× 1

More Python examples at level 1

← Python typing practice