I have a python string like this:
expression = "test[1]"
var1 = "{%s}" % expression
str1 = f"{var1}"
print(str1.format(test="world"))
I can only change the first line (expression affectation) and i want to test if second character is 'o' inside the expression, in order to display result on console.
if have tried this:
expression = "test[1]=='o'"
expression = "(test[1]=='o')"
expression = "1 if test[1]=='o' else 0"
Nothing works.
Is there a way to do this ?
Thanks