0
How do I change stringed operators to normal
A=ā+ā # i have to change strā+ā to normal + Iāve searched what type does normal plus sign have. In order to change str to that type. But canāt find them on the internet
7 Answers
+ 1
the others will require using of objects and methods. in some sense it will be customized "eval". but " eval " is very dangerous, and custom solution could be preferable.
+ 1
in what sense do you want "normal". + is an operator, and cannot be assigned to a variable A=..
+ 1
???
strings are always in " or '.
when you print ("+") it will be +
what is your ultimate goal?
+ 1
fine. one way is
res = eval (str(num[0])+oper[0]+ str(num[1]))
will give you res = 3
0
ā+ā ā> +
0
Operators=[ā+ā,ā-ā,ā*ā]
Numbers=[1,2,3]
I am trying to combine these two
str(Numbers[0])+operators+ str(Numbers[1])
(This equals toā1+2ā)
And then change them to ānot stringā
In here when i do int(ā1+2ā) it doesnāt work because of the plus
0
Thanks. You said one way is there another way too?