# roll dice and keep rolling until you quit # # load the random class # import random # # assume user wants to roll the dice # rollem = "yes" # # now roll repeatedly until done # while rollem == "yes": # it's a 20-sided die; note we add 1 because the random number # generated is between 0 and 19 (20-1) inclusive; by adding 1, # we will print a number between 1 and 20 die = random.randrange(20) + 1 print "You rolled a 20 sided die and", die, "came up.", # # see if she wants to go again # rollem = raw_input("Again (yes/no)? ") while rollem != "yes" and rollem != "no": # sorry, I don't understand that ... rollem = raw_input("I only understand 'yes' or 'no'. Again (yes/no)? ")