i have some coding that i would like to repeat here is the coding how do i do it??? it is for a calculator and i want to repeat the last bit ("main()")
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
#returns the result of adding num1 + num2 def add(num1, num2): return num1 + num2 #returns the result of subtracting num1 - num2 def minus(num1, num2): return num1 - num2 #returns the result of mutipliying num1 * num2 def multiply(num1, num2): return num1 * num2 #returns the result of dividing num1 / num2 def divide(num1, num2): return num1 / num2 def main(): operation = input ( "what do you want to do (+,-,*,/): " ) if (operation ! = '+' and operation ! = '-' and operation ! = '*' and operation ! = '/' ): #invalid operation print ( "please enter a vaild operation" ) else : num1 = int ( input ( "Enter num1: " )) num2 = int ( input ( "Enter num2: " )) if (operation = = '+' ): print (add(num1, num2)) elif (operation = = '-' ): print (minus(num1, num2)) elif (operation = = '*' ): print (multiply(num1, num2)) else : print (divide(num1, num2)) main() |