How to remove double quotes to make tuple in python from the array

Viewed 14

Input is

["('ABCD','ABCD.pdf',10)", "('ABCD','ABCD.pdf',14)", "('ABCD','ABCD.pdf',15)"]

Expected output

[('ABCD','ABCD.pdf',10),('ABCD','ABCD.pdf',14), ('ABCD','ABCD.pdf',15)]
1 Answers

One quick solution is to use eval and map. Example:

text = ["('ABCD','ABCD.pdf',10)", "('ABCD','ABCD.pdf',14)", "('ABCD','ABCD.pdf',15)"]
out = list(map(eval, text))

Out contains the desired result.

See the python docs here

Related