Why Is This If Else Statement Giving A Syntax Error?
#--------------input-------------# def getmove(): global room,posx,posy,moves,dead,inventory,foods,drinks,food,water move=input() if move == 'e': posx=posx+1
Solution 1:
In this part of the code:
iffood== 0orwater== 0:
dead = True
seeifdead(room,posx,posy,moves,dead,inventory,foods,drinks)
moves+=1
food-=1
water-=1else:
print('I dont understand')
moves-=1
food+=1
water+=1
You have code between your if
and its corresponding else
.
This will lead to a syntax error.
iffood== 0orwater== 0:
dead = True
seeifdead(room,posx,posy,moves,dead,inventory,foods,drinks)
moves+=1
food-=1
water-=1else:
print('I dont understand')
moves-=1
food+=1
water+=1
Compare it with the code above and see the difference.
Post a Comment for "Why Is This If Else Statement Giving A Syntax Error?"