Reputation: 45
I keep getting a syntax error for the very last else in this set of code and I have no idea why. Its not an error with spacing its just syntax so I Don't understand what I'm doing wrong. I was wondering if someone could help. The code is below.
if pcolor == winner:
print ('Correct!')
while player == correct:
phl = input('Higher or lower?').strip().lower()
randcard = computer_pick_card()
if randcard == 'A':
player = correct
print ('The card was an Ace')
print ('Correct!')
else:
if last_card != ():
if phl == higher:
if randcard >= last_card:
player = correct
print ('The card was ', randcard)
print ('Correct!')
elif randcard < last_card:
player != correct
print ('The card was ', randcard)
print ('You lose')
elif phl == lower:
if randcard >= last_card:
player != correct
print ('The card was ', randcard)
print ('You lose')
elif randcard < last_card:
player == correct
print ('The card was ', randcard)
print ('Correct!')
else:
if phl == higher:
if randcard >= card2:
player = correct
print ('The card was ', randcard)
print ('Correct!')
elif randcard < card2:
player != correct
print ('The card was ', randcard)
print ('You lose')
elif phl == lower:
if randcard > card2:
player != correct
print ('The card was ', randcard)
print ('You lose')
elif randcard <= card2:
player == correct
print ('The card was ', randcard)
print ('Correct!')
last_card = randcard
return last_card
last_card = ()
else:
print ('You lose')
Upvotes: 1
Views: 75
Reputation: 31131
In python spacing is syntax.
You don't have the spacing right.
if ...
...
last_card = ()
else:
...
Should be
if ...
...
last_card = ()
else:
...
Upvotes: 2