jeudi 28 novembre 2019

One line condition assignment

The author of the following code stack = root and [root] wrote that it means:

if root:
  stack = root
else:
  stack = None

I have seen the post One line if-condition-assignment and I can understand how it works. But I do not understand how [root] means None. Can anybody explain?

Aucun commentaire:

Enregistrer un commentaire