mardi 1 juin 2021

What's the difference between If not (variable) and if (variable) == false?

I'm learning Python and I just started learning conditionals with booleans

I am very confused though as to the specific topic of "If Not". Could someone please explain to me the difference between :

x = False

if not x:
   print("hello")

if x == False:
   print("hello")

When testing this code on a Python compiler, I receive "hello" twice. I can assume this means that they both mean the same thing to the computer.

Could someone please explain to me why one would use one method over the other method?

Aucun commentaire:

Enregistrer un commentaire