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
3 Answers
+ 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
+ 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)
0
Oh thanks i totally forgot