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 (other example)

  • if
  • else
def main():
    a = input('First number: ')
    b = input('Second number: ')

    if int(b) == 0:
        print("Cannot divide by 0")
    else:
        print("Dividing", a, "by",  b)
        print(int(a) / int(b))

    print("Still running")


main()