0

Ive made a simple calculator from wht i learned but it didnt work help pls

The code👇👇 https://code.sololearn.com/cW6lxWGiAJjU/?ref=app

8th Jun 2020, 8:28 PM
Abdellilah elboq
Abdellilah elboq - avatar
3 ответов
+ 3
How are using elif without previous if at line 7? or maybe you are trying to do if user_input == "add": num1 = float(input("")) num2 = float(input("")) result= str(num1 + num2) print("the result is " + result) elif user_input=="multiple": num1=float(input("")) num2=float(input("")) elif stays in same line as if
8th Jun 2020, 8:35 PM
Abhay
Abhay - avatar
+ 1
You really love indentations don't you? I can see that 😉 All you need to do is remove all the unnecessary ones. This will work. user_input = input("") if user_input == "add": num1 = float(input("")) num2 = float(input("")) result= str(num1 + num2) print("the result is " + result) elif user_input=="multiple": num1=float(input("")) num2=float(input("")) result=str(num1 * num2) print("result is "+result) elif user_input =="divide": num1=float(input("")) num2=float(input("")) result=str(num1/num2) print("the result is "+ result) elif user_input =="substract": num1=float(input("")) num2=float(input("")) result=str(num1-num2) print("the result is "+result) elif user_input =="rest": num1=float(input("")) num2=float(input("")) result =str(num1%num2) print("the rest is "+result)
8th Jun 2020, 8:41 PM
Avinesh
Avinesh - avatar
0
Oh thanks i totally forgot
8th Jun 2020, 8:40 PM
Abdellilah elboq
Abdellilah elboq - avatar