0
please check this out ,why is it not working ,
def sum (a,b): add = (a+b) print ('sum of ' ,a , 'and ' ,b , 'is equal to ' , add) print ("thank you") def substract (a,b): diff = (a-b) print ("substraction of ", a , "and ", b , "is equal to " ,diff) print ("thank you") def multiply (a,b): mul = (a*b) print ('multiplication of ' ,a , 'and ' ,b , 'is equal to ' , mul) print ("thank you") def divide (a,b): div = (a/b) print (a , 'divided by ',b , 'is equal to ' , div) print ("thank you") comm = input("what do you want to do : ") if comm ==("add"): add (input("write your no. : "),input("write your second no. : "))
2 Answers
+ 1
Add your code link.
+ 1
EDIT: Sorry, didn't see the main error. There is no function add(). The name of the function is sum().
In the last line, you are taking the input as string. So suppose I enter the numbers 5 and 6. They will be taken as strings "5" and "6" and passed to the sum() function, which will print "5" + "6", which is "56".
You need to convert the input to integer. Use the int() function to do that. So the last line would be
`sum(int(input(....)), int(input(...)))`