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 ответов
+ 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?