I am playing around with Python trying to learn the basics, and as a short test, I wrote the following code:
import random
def random_number():
return int(random.randint(0, 10))
def lottery(input):
num = random_number()
while num != input:
print(num, "Not yet...")
num = random_number()
else:
print(num, "We have a winner!")
lottery(4)
This code works as expected in the console, but I thought it would be interesting to allow a user to enter a number using the input() method, so I changed the function call to the following:
lottery(input("Pick a number between 0 and 10: "))
The result was that the while loop ran indefinitely, crashing the console. I was wondering if anyone had any thoughts as to why, and how to correctly use the input() function as an argument in a function (or, how to write the above code to use the input() function in general).
Thank you very much!