[Tutor] elif statement doesn't work
hongerlapjes
hongerlapjes at gmail.com
Sun Feb 28 16:04:25 EST 2021
For school I have to make a simple roulette game.
If the user inputs "STOP", the game starts. But I cant seem to make the
input STOP. ValueError: invalid literal for int() with base 10: 'STOP'
What am I doing wrong?
"""
ROULETTESPEL
"""
import random
invoer = ["STOP"]
for x in range(37):
invoer.append(x)
getallen = []
def roulette ():
print("Rien ne va plus.")
winnendgetal=(random.randint(0,36))
print("De uitkomst is", winnendgetal)
for winnendgetal in getallen:
fiches +=35
print("Je hebt gewonnen en je hebt nu" , fiches, "fiches.")
else:
if fiches == 0:
print("GAME OVER")
def start ():
fiches = 10
print("Je hebt", fiches, "fiches!")
while fiches > 0:
inzet=input("Op welk getal wil je inzetten?"'\n')
print(inzet)
if int(inzet) >= 0 and int(inzet) <= 36 :
fiches -= 1
getallen.append(inzet)
print(getallen)
print("Je hebt nog", fiches, "fiches over.")
elif str(inzet) == "STOP" :
roulette()
else:
start()
start ()
roulette ()
More information about the Tutor
mailing list