def santa(*says): if not says: return "ho! xmas!" else: return says[0]+"! "+santa(*says[1:])
This is a recursive function with *arg
syntax that has troubled my understanding. What does "if not says
" mean? Is it equal to "if says == False
"? Or "if says is None
"? Because if I substitute it with either of both, it gives an error.
How does it link to:
print(santa())
which has no arguments and outputs
"ho! xmas!"
meaning that it satisfies the first conditional statement.
Aucun commentaire:
Enregistrer un commentaire