Python Forum

Full Version: Random function
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I don't understand my error

x = random (1,5)
if x % 2 == 0:
   print ("even")
else:
   print ("odd")
Where are you getting rando from? If it's from the random module, you generally don't give it parameters, and it returns a float, not an int. You probably want random.randint instead.