468,740 Members | 2,018 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,740 developers. It's quick & easy.

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.com/python/module_random.asp)

#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.randrange(-5,21)
print("Your number is:" , CN)
PlusMinus=["+","-"]
left = random.randrange(-5,21)
right = random.randrange(-5,21)
Operator = random.choice(PlusMinus)
Choice = input("Left Or Right?: ")
print("(Left)" , Operator + str(left),"(Right)" , Operator , str(right)
if Choice == "Right":
CN = str(CN) + str(right)
int(CN)
elif Choice == "Left":
CN = str(CN) + str(left)
int(CN)
3 Weeks Ago #1
1 1186
SioSio
252 128KB
The ")" in the print statement is missing.
Expand|Select|Wrap|Line Numbers
  1. print("(Left)" , Operator + str(left),"(Right)" , Operator , str(right))
3 Weeks Ago #2

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

1 post views Thread by Tersia Ehlert | last post: by
1 post views Thread by =?Utf-8?B?TXVydWdlc2FuUA==?= | last post: by
2 posts views Thread by kkshansid | last post: by
1 post views Thread by CARIGAR | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.