Basic Calculator in Python -


i'm new python. tried make basic calculator, can't find problem. returns 0 exit code, nothing appears, no input no nothing. appreciated. thank you.

def add(num1, num2):     return num1 + num2  def subtract(num1, num2):     return num1 - num2  def div(num1, num2):     return num1/num2  def multi(num1,num2):     return num1*num2  def main():     operation = input("what want do?(+, -, *, or /):")     if (operation != "+" , operation != "-" , operation != "*" , operation != "/"):         print("your input invalid. please enter valid input.")     else:         num1 = float(input("enter value num1: "))         num2 = float(input("enter value num2: "))         if (operation == "+"):             print(add(num1, num2))         elif (operation == "-"):             print(subtract(num1, num2))         elif (operation == "*"):             print(multi(num1,num2))         elif (operation == "/"):             print(div(num1,num2))      main() 

based on code above, never running main(). right now, have said definition of main prompt user, check if input correct, , math. main() @ end causes program repeat after doing (not sure if want loop or not).

if don't want loop, , want run calculator once, remove indent of last main(), because right indentation means inside of def main(). move left @ same indentation level def main(): , program should run fine.


Comments