1

I came across this problem in my project in which I have lists which append from a life to a list. Please see below.

Log_info = [ "['carl@gmail.com', 'carl120', 'Carl']", "['brandi.love@gmail.com', 'brandih0t', 'Brandi']" ]

Above is the list that have been pull from a file (TXT)

Below is what I want it to look like: I want to remove "" so they are sub list in a list, but I can't seem to find how.

Log_info = [ ['carl@gmail.com', 'carl120', 'Carl'], ['brandi.love@gmail.com', 'brandih0t', 'Brandi'] ]
halfer
  • 18,701
  • 13
  • 79
  • 158
Titler
  • 15
  • 3

1 Answers1

5

I'd use ast.literal_eval

>>> from ast import literal_eval
>>> [literal_eval(i) for i in Log_info]
[['carl@gmail.com', 'carl120', 'Carl'],
 ['brandi.love@gmail.com', 'brandih0t', 'Brandi']]
Cory Kramer
  • 98,167
  • 13
  • 130
  • 181