Pas d'instruction de retour¶
In [1]:
def r1():
print('pas de retour ?')
# pas d'instruction return
In [2]:
ret = r1()
In [3]:
print(ret)
Avec instruction de retour¶
In [4]:
def r2(a, b):
if a > b:
print('a plus grand que b')
return a # interruption
print('et la suite ?')
In [5]:
r2(3, 1)
Out[5]:
Retour multiple¶
In [6]:
def r3(pl):
return min(pl), max(pl) # retour multiple possible ?
In [7]:
lnb = [10, 7, 9, 3, 17, 5]
ret1, ret2 = r3(lnb)
In [8]:
print(ret1, ret2)
In [9]:
print(type(r3(lnb)))