I got this code
firstId = True
for x in [1,2,3,4,5]:
firstId = False if firstId else print(str(x)+ " " + str(firstId))
print ("What is happening here ???")
firstId = True
for x in [1,2,3,4,5]:
if firstId:
firstId = False
else:
print(str(x)+ " " + str(firstId))
And strangly i have this output
2 False
3 None
4 None
5 None
What is happening here ???
2 False
3 False
4 False
5 False
From my understanding both if statement should behave the same way.But the boolean is not. I can't understand why the boolean somehow becomes None. Can someone explain what is happening?
Aucun commentaire:
Enregistrer un commentaire