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.
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)
print((message + '\n') * number_of_times)
Thank you for your interest in this question.
Because it has attracted low-quality or spam answers that had to be removed, posting an answer now requires 10 reputation on this site (the association bonus does not count).
Would you like to answer one of these unanswered questions instead?