Logic Building
# Take string input
s = input("Enter a string: ")
n = int(input("Enter number of times: "))
# Duplicate
result = s * n
print(result)Output
Enter a string: Hello Enter number of times: 3 HelloHelloHello
Use * operator to repeat string.
Key Concepts:
- s * n repeats string n times
- Concatenates copies
- Simple multiplication