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

29th Dec 2017, 8:29 AM
Yololab
Yololab - avatar
7 Respostas
+ 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.
29th Dec 2017, 9:30 AM
yuri
+ 1
in what sense do you want "normal". + is an operator, and cannot be assigned to a variable A=..
29th Dec 2017, 8:38 AM
yuri
+ 1
??? strings are always in " or '. when you print ("+") it will be + what is your ultimate goal?
29th Dec 2017, 8:47 AM
yuri
+ 1
fine. one way is res = eval (str(num[0])+oper[0]+ str(num[1])) will give you res = 3
29th Dec 2017, 9:20 AM
yuri
0
“+” —> +
29th Dec 2017, 8:41 AM
Yololab
Yololab - avatar
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
29th Dec 2017, 9:16 AM
Yololab
Yololab - avatar
0
Thanks. You said one way is there another way too?
29th Dec 2017, 9:23 AM
Yololab
Yololab - avatar