0

Can you explain me what's wrong with this code ?

print('Hello ') print ('**** Welcome to calculator ****') print ('For addition , please enter "add"') print ('For subtraction , please enter "sub"') print ('For multiplication , please enter "mul"') print ('For division , please enter "div"') User_input = input(":") if User_input == "add" : num1 = float(input("\nEnter 1st number ")) num2 = float(input ("\nEnter 2nd number ")) result = str(num1 + num2) print("\nYour result is "+ result) elif User_input == "sub" : num1 = float(input("\nEnter 1st number ")) num2 = float(input ("\nEnter 2nd number ")) result = str(num1 - num2) print("Your result is "+ result) elif User_input == "div" : num1 = float(input("\nEnter 1st number ")) num2 = float(input ("\nEnter 2nd number ")) result = str(num1 / num2) print("Your result is "+ result) elif User_input == "mul" : num1 = float(input("\nEnter 1st number ")) num2 = float(input ("\nEnter 2nd number ")) result = str(num1 * num2) print("Your result is "+ result) else: print("Wrong")

30th May 2020, 5:20 AM
Ahmad Naweed
3 Answers
+ 2
Ur bug is u r using sololearn for multiple in input Try to copy ur code in PyDroid and run their all ur bugs will get solved
30th May 2020, 5:24 AM
Abhay
Abhay - avatar
+ 2
Abhay Yes you are right!!! Ahmad Naweed There's no bug in your code... It is sololearn's limitation... It does not support multiple inputs...
30th May 2020, 7:02 AM
Namit Jain
Namit Jain - avatar
+ 1
What is complier telling u about bug
30th May 2020, 5:24 AM
Abhay
Abhay - avatar