def test_number(x, y):
if x == y or abs(x-y) == 5 or (x+y) == 5:
return True
else:
return False
print(test_number(7, 2))
print(test_number(3, 2))
print(test_number(2, 2))
When run in jupyter notebook, it executes with O/P:True when run in python shell cmd, it gives invalid syntax
Error is in the ident. Python is an ident base language. Correct example.
def test_number(x, y):
return x == y or abs(x-y) == 5 or (x+y) == 5
print(test_number(7, 2))
print(test_number(3, 2))
print(test_number(2, 2))
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.