what’s this indentationError?

In python, there are identation rules to know how the program should execute commands. This is the way python recognize when a function, a conditional statement or for, while statements start and end. In your case, for example, the elif statement should be at the same “level” as your initial if statement start:

print("Welcome to calculator.py")
print ("your options are :")
print ("")
print ("1) Addition")
print ("2)Subtraction")
print ("3) Multiplication")
print ("4)Division")
print ("Choose your option")

#this adds 2 numbers given

def add (a,b):
    print(a, "+" ,b, "=" ,a+b)

#this subtracts 2 numbers given
def sub (a,b):
    print(a, "-" ,b, "=" ,b-a)

#this multiplies 2 numbers given
def mul(a,b):
    print(a, "*" ,b, "=" ,a*b)

#this divides 2 numbers given
def div(a,b):
def div(a, "https://stackoverflow.com/" ,b, "=" ,a/b)

loop = 1
choice = 0
while loop == 1:
    choice = menu()

if choice == 1:
    add (input("Add this: "),input ("to this: "))

elif choice == 2:
    sub(input("Subtract this: "),input ("from this: "))

elif choice == 3:
    mul (input("Multiply this: "),input ("by this: "))

elif choice == 4:
    div(input("Divide this: "),input ("by this: "))

elif choice ==5:
    loop = 0

Browse More Popular Posts

Leave a Comment