I am trying to make a python code for the game of roulette, but every line is returning "invalid syntax". It might be some sort of indentation error, but I am new at Python and can't figure it out for the life of me. Any help would be much appreciated!
import random
def roulette():
"Game of roulette"
chips=10
L=[1,2,3,4,5,6,7,8,9,10]
while chips > 0:
x=int(input("You have 10 chips. How many do you want to bet? ")
while x not in L:
x=int(input("You bet between 1 and 10 chips. Bet 10 or less chips. ")
y=input("What do you want to bet on? Green, Red or Black? ")
z=random.randint(0,10)
print(z)
if x == z:
chips=chips+(9*x)
print("You have %i chips" %chips)
elif ((y.lower() == "green" and z == 0) or (y.lower() == "red" and z in [1,3,5,7,9]) or (y.lower() == "black" and z in [2,4,6,8,10])):
chips=chips+x
print("You have %i chips" %chips)
else:
chips=chips-x
print("You lost. You now have %i chips" %chips)
w=input("Do you want to play another round? Yes or No? ")
if w.lower() == "no" or chips == 0:
print("The game is over! You had %i chips left" %chips)
break
roulette()
x. I figured this out by running your code through Pylama, a linter. BTW welcome to SO! Please take the tour and read How to Ask. In the future for debugging questions, you need to make a minimal reproducible example including the full error message.