Duplicate String N Times
Print string n times.
BeginnerPhase 5 - Category 4: String TransformationExample 7 of 10
duplicate-string-n-times.py
1# Take string input2s = input("Enter a string: ")3n = int(input("Enter number of times: "))45# Duplicate6result = s * n7print(result)
Output
Enter a string: Hello Enter number of times: 3 HelloHelloHello
What's going on
Use * operator to repeat string.
Key Concepts:
s * n repeats string n times
Concatenates copies
Simple multiplication
🔗Related Content
- 📖
Phase 5 - Learn Concepts
Review Phase 5 concepts and explanations
- 📝
Phase 5 - Quiz
Test your Phase 5 understanding with quiz questions
- 💻
Phase 5 - All Practice Problems
Explore all practice problems for Phase 5
- 🎓
Master Your Logic Building - Complete Course
Browse all phases and tutorials
- 🧠
Logic Building Overview
Learn about the complete logic building curriculum