Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Toggle

  • not

machine_is_on = False
print(machine_is_on)   # False

# Instead of this:

if machine_is_on:
    machine_is_on = False
else:
    machine_is_on = True

# Write this:

machine_is_on = not machine_is_on
print(machine_is_on)   # True

machine_is_on = not machine_is_on
print(machine_is_on)   # False