Q:

Coding a calculator in python, need some assistance

Please help me understand what im doing wrong: trying to code a calculator. 
Ive tried using debuggers. to no avail.
I keep getting indentation errors, and Im not sure what Im doing wrong. Maybe its my loops? 
Tried moving things around, still not giving me any output. Can someone look at my loops and advise me?
Please help guide a young coder trying to learn! 
    while False: 
        options = [1, 2, 3, 4] 
        choice = input('Enter choice(1/2/3/4):')
        try:
            choice = int(choice)
            if choice not in options:
                print("Invalid input.")
                break

            num1 = int(input("Enter first number: "))
            num2 = int(input("Enter second number: "))

        except:
            print("Please use one of the following(1/2/3/4): ")
            continue 
        break

    choice = int(choice)

    if choice == 1:
        print_result(multiply(num1, num2))

    elif choice == 2:
        print_result(divide(num1, num2))

    elif choice == 3:
        print_result(subtract(num1, num2))

    elif choice == 4:
        print_result(add(num2, num1))

    else:
        print("Invalid input")

    while True:
        try:
            retry = str(input("Do you wish to do another calculation(y/n): "))
        except:
        if retry == 'y':
             break
        elif retry == 'n':
             break
        else:
            print("Invalid Input - Use y or n")
            continue

    if retry == 'n':
        print("Thanks for using our amazing calculator!!!")
        break

    print("Restarting...")
    time.sleep(2)    

A:

I see the mistakes in your code,follow these instructions to get it right:

Indentation has to be uniform , i.e , four spaces or a tab,use either one of those
while False: will never execute , change it to while true
Make sure to define all your functions like multiply , etc.
try the builtin eval() function , but do not use for any production as it executes any python code sent to it

    print( eval( input("Input equation here:") ) )

Write the whole calculator code in a function and use a return statement to exit every loop at once to end program like this :

    def myfunc():
        ...some code...
        if retry == 'n':
            return 0
        else:
            ...more code...

Make sure to check out this free e-book
Hope this helps!!

