I have a list and items are strings, but from some operation i got the list as string items are enclosed with extra "'string' ". How to get rid of that.
My code sample is
import ast d = ["'WORKSHOP'", "'KIDS'", "'EXHIBITION'", "'FANTASY'", "'FESTIVAL'"] result = ast.literal_eval(d) ValueError: malformed node or string: ["'WORKSHOP'", "'KIDS'", "'EXHIBITION'", "'FANTASY'", "'FESTIVAL'"] I want the output as:
result = ['WORKSHOP', 'KIDS', 'EXHIBITION', 'FANTASY', 'FESTIVAL'] For integers:
res = [123, 345, 566, 78]
ast?