Sudarshan kumar
Sudarshan kumar

Reputation: 1585

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

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)]

Upvotes: 1

Views: 42

Answers (1)

MennoK
MennoK

Reputation: 488

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

Upvotes: 2

Related Questions