My calculator is using strings instead of integers and I am using pydroid 3 | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

My calculator is using strings instead of integers and I am using pydroid 3

def calculate(num1, sign, num2): try: str(sign) int(num1, num2) except: print("invalid input") if sign == "+": answer= num1+num2 return(answer) elif sign == "×": answer= num1*num2 return (answer) elif sign == "÷": answer= num1/num2+num1%2 return(answer) elif sign == "-": answer= num1-num2 return (answer) else: print("Invalid input") looptimes=0 while True: if looptimes ==0 : num1=input('first number : ') sign=input("sign : ") num2=input("second number : ") else: print(answer) sign=input("sign : ") num2=input(" second number: ") print("Type More for more nos " ) print("Type Enter for results") motive=input("type here: ") if motive == "Enter": answer=calculate(num1, sign , num2) print(answer) break print ('finished') elif motive == "More": answer = calculate(num1 , sign, num2) num1=answer looptimes=looptimes+1 else: break print( "invalid input") It keeps adding strings please help me

14th Sep 2021, 3:36 PM
Richard
Richard - avatar
3 Answers
+ 4
Richard instead of using input by itself try int(input()) where applicable as numbers
15th Sep 2021, 4:19 AM
BroFar
BroFar - avatar
+ 2
Looks like your code is big enough. So please post it in the code playground and attach the code with a description.If you don't know how to do it then you can have a look at it: https://www.sololearn.com/post/75089/?ref=app
14th Sep 2021, 5:07 PM
Pariket Thakur
Pariket Thakur - avatar
0
Thankyou but it still does not work
15th Sep 2021, 10:18 AM
Richard
Richard - avatar