-There are two types, one with no return value and the other with.
def a(x,y):
if x==y:
print("same")
return
print(x,y)
else:
print("different")
a(1,1)
a(1,0)
Execution result
same
different
-Print (x, y) after return is not executed
def a(x,y):
if x==y:
return ("{}When{}Are equal").format(x,y)
else:
return ("{}When{}Are not equal").format(x,y)
a(1,1)
a(1,0)
Execution result
'1 and 1 are equal'
'1 and 2 are not equal'
Recommended Posts