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

Conditionals: if - else

  • if
  • else
def main():
    expected_answer = "42"
    inp = input('What is the answer? ')

    if inp == expected_answer:
        print("Welcome to the cabal!")
    else:
        print("Read the Hitchhiker's guide to the galaxy!")

    print("This always happens")

main()