import random
def roll(sides=6):
num_rolled=randomint(1,sides)
return num_rolled
def dice_game():
sides = 6
while True:
roll_again = input("Ready to roll? Enter=ROLL. Q=Quit.")
if roll_again.lower() != "q":
num_rolled = roll(sides)
print("You rolled a ", num_rolled)
else:
rolling = False
print("Thanks for playing.")
dice_game()
when I try to run it through the command line on my local machine i get the following error:
Traceback (most recent call last):
File "SimpleDiceRollingSimulation.py", line 17, in <module>
dice_game()
File "SimpleDiceRollingSimulation.py", line 10, in dice_game
roll_again = input("Ready to roll? Enter=ROLL. Q=Quit.")
File "<string>", line 1, in <module>
NameError: name 'q' is not defined