- 5
I'm having problems with the simple calculator. Help
11. break 12. elif user_input=="add": 13. ... 14. elif user_input=="subtract": 15. ... I tried out this code, buh it shows me SyntaxError: invalid syntax in LINE 13. help
7 Respuestas
+ 5
Well, how about showing us what you actually put in line 13 instead of "..."? (Unless you DID put "...", which would explain the synthax error.)
+ 2
You were supposed to put the actual code to handle the operation instead of the 3 dots.
+ 1
the ... is just a placeholder, go through the rest of the tutorial to finish each statement
eg.
if user_input="add":
num1=float (input ("enter the 1st number"))
num2=float (input ("enter the 2nd number"))
result=str(num1+num2)
print("answer is: "+result)
0
I actually put the three dots in line 13 (...)
That was how I saw it in the tutorial of A SIMPLE CALCULATOR
0
Hmm.. What code?
Kinda confused here
0
you need to write actual codes instead of the ...
if you fill out the blanks in "creating a calculator, I'd look like this:
elif user_input=="add"
num1=float(input("Enter a number:"))
num2=float(input("Enter another number:"))
result=str(num1+num2)
print("The answer is"+result)
elif user_input=='substract'
num1=float(input("Enter a number:"))
num2=float(input("Enter another number:"))
result=str(num1-num2)
print("The answer is"+result)
elif user_input=="multiply"
num1=float(input("Enter a number:"))
num2=float(input("Enter another number:"))
result=str(num1*num2)
print("The answer is"+result)
elif user_input =="divide"
num1=float(input("Enter a number:"))
num2=float(input("Enter another number:"))
result=str(num1/num2)
print("The answer is"+result)
else:
print("Unknown input")
0
Please See My New Code Basic Calculator (Web)