Ask coding questions

← Back to all posts
else:
LillianaRoss (0)

I ran into a problem with line 25. Repl says the else: isn't a valid syntax. Anyone know how to help?

Comments
hotnewtop
poetaetoes (322)

You don't have a regular if statement before it, so i fixed it. Not only that, you had a lot of if statements that was supposed to be "if blah == blah" not "elif".
I fixed those mistakes and you finish it up yourself cuz idk what the endresult is supposed to me

  for entry in list:
    print ("1 + list.index(entry),") 
    print (")" + entry)
return input(question) - 1
items = ["pot plant", "painting", "vase", "lampshade", "shoe", "door"]
keylocation = 2
keyfound = 0
loop = 1
print ("last night you went to sleep in the comfort of your own home") 
print ("Now, you found yourself locked in a room. You don't know how")
print ("you got there, or what time it is. In the room you can see")
print ((items) == "things")
for x in items: 
  print ("x")
print ("")
print ("the door is locked. Could there be a key somewhere")
while loop == 1:
  choice = menu(items, "What do you want to inspect?") 
  if choice == 0:
    if choice == keylocation:
      print ("You found a small key in a the potted plant")
print ("")
keyfound = 1

if keyfound == 120:
  print ("") 
else:
  print ("You found nothing in the potted plant")
  print ("")
if choice == 1:
  if choice == keylocation:
    print ("you found a small key behind the painting")
    print ("")
    keyfound = 1
else: 
  print ("You found nothing behind the painting")
  print ("")
if choice == 2:
  if choice == keylocation:
    print ("you found a small key in the vase")
    print ("")
    keyfound = 1
else: 
  print ("You found nothing in the vase")
  print ("")
  keyfound = 1
if choice == 3:
  if choice == keylocation:
    print ("You found a small key behind the lampshade")
    print ("")
    keyfound = 1
else:
  print ("You found nothing behind the lampshade")
  print ("")
if choice == 4:
  if choice == keylocation:
    print ("You found a small key in the shoe")
    print ("")
    keyfound = 1
else: 
  print ("You found nothing in the shoe")
  print ("")
if choice == 5:
  if keyfound == 1:
    loop = 0
    print ("You put in the key, turn it, and hear a click")
    print ("")
else: 
  print ("The door is locked, you need to find the key")
  print ("") 
print ("Light floods into the room as \ you open the door to your freedom")
Wumi4 (531)

Your code seems pretty messed up. I can help, but I'm on my phone.