I wan't to make a program which will print an input a certain number of times based on another input.
msg = input ("What is your message?")
times = input ("How many times do you wan't your message repeated?")
for times in range(6):
print(msg)
I wan't to make a program which will print an input a certain number of times based on another input.
msg = input ("What is your message?")
times = input ("How many times do you wan't your message repeated?")
for times in range(6):
print(msg)
You have to use raw_input() if you want to enter strings. There is also an error in your range-operator. Use it like this:
msg = raw_input('What is your message?')
times = raw_input("How many times do you wan't your message repeated?")
for i in range(int(times)):
print(msg)
Output:
What is your message? Hello World.
How many times do you wan't your message repeated?3
Hello World.
Hello World.
Hello World.
Process finished with exit code 0
You need to iterate on a range of numbers between 0 and times
, however you also need to convert times
to an integer.
In order to do that your for
loop needs to be for i in range(int(times)):