am kinda having problem problem applying d if and elif especially with the == stuff I tried building a calculator but I can't get it to respond or reply cause I keep on getting error at user input | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

am kinda having problem problem applying d if and elif especially with the == stuff I tried building a calculator but I can't get it to respond or reply cause I keep on getting error at user input

14th Oct 2016, 8:20 PM
Stephen Antai
Stephen Antai - avatar
2 Answers
+ 3
Here is how you can do it: a = int(input("operand1?")) b = int(input("operand2?")) op = input("operator?) if op == "+": print(str(a+b)) elif op == "-": print(str(a-b)) #etc.
14th Oct 2016, 9:13 PM
Zen
Zen - avatar
+ 1
What exactly is the problem? if you are trying to get input from the user use something like this: inputstr1 = input("Enter a equation/problem: ") This will give you the input as a string.
14th Oct 2016, 9:06 PM
Alec Groseclose
Alec Groseclose - avatar