samedi 28 avril 2018

syntax error in if...else condition

I'm learning programming in Python and I'm stuck with a syntax error in the line 8 in the following code

x = int(input('Add x:\n'))
y = int(input('Add y:\n'))
if x == y :
    print('x and y are equal')
else :
    if x < y :
        print('x is less than y')
    else x > y :
        print('x is greater than y')

I just don't see what's wrong there.

The full error is:

Traceback (most recent call last):
  File "compare.py", line 8
    else x > y :
         ^
SyntaxError: invalid syntax

Aucun commentaire:

Enregistrer un commentaire