Generating random numbers in python
don't mean to bother, but I'm new to programming, and i'm not entirely
sure what to do here. I'm trying to make a basic dice roller. When i run
this program in Codeskulptor, it throws an error on the randint function.
Can I not set the range for it using raw_input plugged into variables? Is
there a different function I should use? Thanks, and sorry if im not using
correct terminologies.
"""Program to roll random numbers within the ranges set."""
import random
sides_of_die=raw_input("Enter how many sides your die has: ")
number_of_dice=raw_input("Enter number of dice you have: ")
total=sides_of_die*number_of_dice
rollinput=raw_input("Would you like to roll now?")
rollinputcap=rollinput.upper()
if rollinputcap =="Y":
print random.randint(number_of_dice,total)
else:
print "What do you want then?"
No comments:
Post a Comment