x = int(input("Choose the number of times you want to spam. "))
y = input("What message do you want to spam? ")
w = x + 1
for i in range(1,w):
print(y)
Any way to make this program better? I'm currently learning Python.
range(1, w)
- get used to using zero-based numbering_
as the name for a loop variable when you won't actually be referring to that variable anywhere. So:
def main():
number_of_times = int(input("Choose the number of times you want to spam. "))
message = input("What message do you want to spam? ")
for _ in range(number_of_times):
print(message)
Alternatively:
print((message + '\n') * number_of_times)