Python not Keyword
A logical operator that returns
True if the statement is
False if the statement is
success = False if not success: print('Sadly, we did not succeed') # but what if we turn things around? success = not success # success will now be 'not False' which is True if (success): print('Yes, we succeeded!')
Sadly, we did not succeed Yes, we succeeded!
You can use the not operator in other interesting ways, for example:
print(not 1 < 2) print(not 1 in [2, 3, 4])