How do i call these functions without an error? Python


  • Hi, I'm confused on how to call these functions I'm continuously getting error can you please help me.

    I am also unsure on how parameters work and don't know what I need to write in them, i'm a bit of noob so will need you to explain thoroughly thank you

    I am trying to get a dice roll and then the player chooses which counter to move, the program will then automatically minus the movement from the counters position

    counter = ()
    postiony_red1 = 605
    postiony_red2 = 605

    def dice_roll():
        import random
        dice = random.randint(1, 4)
        print("You rolled a", dice)
        if dice == 1 :
            print("You can step forward", dice, "move")
        elif dice == 2 or dice == 3:
            print("You can move", dice, "steps forward")
            print("You can move 1 space back")
        input("Press return")
        return dice

    def move(dice):
        if dice == 1:
            move = -60
        elif dice == 2:
            move = -120
        elif dice == 3:
            move = -180
        elif dice == 4:
            move = 60
        return move

    def ask_player():
        while counter != ("counter 1") or ("counter 2"):
            counter = input("Do you wish to move counter 1 or counter 2?")
            return counter

    def counter_postion():
        if counter == ("counter 1"):
            move += postiony_red1
            print("total move is", move)
        elif counter == ("counter 2"):
            move += postiony_red2
            print("total move is", move)


    • Moved by litdev Wednesday, October 22, 2014 3:29 PM
    Wednesday, October 22, 2014 1:21 PM


All replies

  • This forum section here is about Small Basic programing language!

    I dunno Python, but the few droplets I've heard about is that Python is very strict about global variables!

    And that every time we need to assign values to them, we gotta declare it w/ global keyword inside each function that needs it:

    def ask_player():
        global counter
        while counter != "counter 1" or "counter 2":
            counter = input("Do you wish to move counter 1 or counter 2?")
            return counter

    Click on "Propose As Answer" if some post solves your problem or "Vote As Helpful" if some post has been useful to you! (^_^)

    • Edited by GoToLoop Wednesday, October 22, 2014 2:01 PM
    Wednesday, October 22, 2014 1:59 PM
  • Might try them over here.




    Regards, Dave Patrick ....
    Microsoft Certified Professional
    Microsoft MVP [Windows]

    Disclaimer: This posting is provided "AS IS" with no warranties or guarantees , and confers no rights.

    Thursday, October 23, 2014 1:15 AM