Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Random function
#1
I don't understand my error

x = random (1,5)
if x % 2 == 0:
   print ("even")
else:
   print ("odd")
Reply
#2
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.
Craig "Ichabod" O'Brien - xenomind.com
I wish you happiness.
Recommended Tutorials: BBCode, functions, classes, text adventures
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Noob here. Random quiz program. Using a while loop function and alot of conditionals. monkeydesu 6 1,376 Sep-07-2022, 02:01 AM
Last Post: kaega2
  basic random number generator in replace function krug123 2 2,027 Jul-31-2020, 01:02 PM
Last Post: deanhystad
  random variable function? Novice_fanatic 4 2,763 Oct-08-2019, 01:22 PM
Last Post: jefsummers

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020