Search code examples
pythonpython-3.4traceback

TRACEBACK Python Die Game


I am writing a die simulation game to better understand the basics of python, but... It throws up a Traceback Error. It would be greatly appreciated if you could assist me in fixing this

import random


def DiceSize():
    DieSize= int(input("""Please pick a dice size,
4 Sides
6 Sides
12 Sides"""))
    if not (DieSize == 4 or DieSize == 6 or DieSize == 12):
        print("Thats not right!")
        DiceSize()
    else:
        print("You have picked %i" % DieSize)
        RollDice()

def RollDice():
    if DieSize == 4:
        min = 1
        max = 4
        print("ROLLING")
        print (random.randint(min, max))
        RollAgain()
    elif DieSize == 6:
        min = 1
        max = 6
        print("ROLLING")
        print(random.randint(min, max))
        RollAgain()
    else:
        min = 1
        max = 12
        print("ROLLING")
        print(random.randint(min, max))
        RollAgain()

def RollAgain():
    roll_again = input("Do you want to roll again: ").lower()

    if roll_again == "y":
              DiceSize()
    else:
              print()

DiceSize()

Solution

  • your problem is that you arent passing the diesize

        RollDice(DieSize)
    
    def RollDice(DieSize):