Python 3.x can';t使用以下代码找出错误
我是python新手,试图在下面的代码中找出错误Python 3.x can';t使用以下代码找出错误,python-3.x,Python 3.x,我是python新手,试图在下面的代码中找出错误 x = int(input("input x")) y = int(input("input y")) if x>y : x -= y elif y>x: x += y else if x==y : print("y = ", y) print("x= ", x) 如果代码未正确缩进,Python将抛出编译错误;如果在Python中无效,则语法为elif 错误: File "test.py", line 15 x -
x = int(input("input x"))
y = int(input("input y"))
if x>y :
x -= y
elif y>x:
x += y
else if x==y :
print("y = ", y)
print("x= ", x)
如果代码未正确缩进,Python将抛出编译错误;如果
在Python中无效,则语法为elif
错误:
File "test.py", line 15
x -= y
^
IndentationError: expected an indented block
固定代码:
x = int(input("input x"))
y = int(input("input y"))
if x>y :
x -= y
elif y>x:
x += y
elif x==y :
print("y = ", y)
print("x = ", x)
File "test.py", line 18
else if x==y :
^
SyntaxError: invalid syntax
x = int(input("input x"))
y = int(input("input y"))
if x>y :
x -= y
elif y>x:
x += y
elif x==y :
print("y = ", y)
print("x = ", x)