def test1():
def test2():
if False:
return 1
else: return 2
test2()
I don't know why, but this function isn't returning the 2 it should return. But when we do that:
def test1():
def test2():
if False:
return 1
else: print(2)
test2()
It prints the 2 on the screen. Why this is happening?
ps: I know we don't need this else to return 2 if the if condition is false. But I'm curious because if we use this test2 as not being a nested function, it returns 2 without a problem.
Aucun commentaire:
Enregistrer un commentaire