I came across this question for the interview. I had to convert the string to Boolean and return the Boolean value
For ex s="3>1>5" => false
I tried using
ans= bool(s) But I always get the answer as True even though the above example gives False if we don't pass it as a string
bool()you'll see that it doesn't evaluate the contents of a string passed to it.eval, then you have to do full-scale parsing - unless the expressions in the strings have very simple, regular structure.