Code isnt working

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • OnlyCactus
    New Member
    • Jul 2021
    • 1

    Code isnt working

    here is my code but for some reason "if Choice == "Right":" is a traceback could I please have some help? (here is link to the random import: https://www.w3schools.c om/python/module_random.a sp)

    #Stay under 21 but above -5 this is that game! Welcome to That Game!

    import random

    print("Hello Welcome to Control! In this game you will need to attempt to stay under 21 yet above -5 by typing left or right based on a format like this one: (Left)x (Right)y where 1 would be x and 2 would be y, now without further a doo let the games begin!")
    Name=input("But first, please enter your username:")
    print("Ok!" , Name , "Lets begin!")
    #CN = Current number
    CN = random.randrang e(-5,21)
    print("Your number is:" , CN)
    PlusMinus=["+","-"]
    left = random.randrang e(-5,21)
    right = random.randrang e(-5,21)
    Operator = random.choice(P lusMinus)
    Choice = input("Left Or Right?: ")
    print("(Left)" , Operator + str(left),"(Rig ht)" , Operator , str(right)
    if Choice == "Right":
    CN = str(CN) + str(right)
    int(CN)
    elif Choice == "Left":
    CN = str(CN) + str(left)
    int(CN)
  • SioSio
    Contributor
    • Dec 2019
    • 272

    #2
    The ")" in the print statement is missing.
    Code:
    print("(Left)" , Operator + str(left),"(Right)" , Operator , str(right))

    Comment

    Working...