📚
String Repetition
Repeating Strings with *
The
*print("Ha" * 3) # → HaHaHa print("-" * 20) # → -------------------- print("🐍 " * 5) # → 🐍 🐍 🐍 🐍 🐍
This is super handy for creating visual separators, borders, or patterns:
print("=" * 30) print(" Welcome!") print("=" * 30) # → ============================== # → Welcome! # → ==============================
The order doesn't matter —
3 * "Ha""Ha" * 3💡💡 Multiplying by 0 gives an empty string:
→"hello" * 0. This can be useful in creative ways!""
main.pySandbox
main.py
Ctrl + Enter