0
Ive made a simple calculator from wht i learned but it didnt work help pls
3 Respuestas
+ 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