-2

I am trying to convert a long string to a list of strings for each item separated with comma.

list = ['05-19.scl, 05-22.scl, 05-24.scl, 06-41.scl']

to :

desired_list= ['05-19.scl', '05-22.scl', '05-24.scl', '06-41.scl']
Axe319
  • 4,255
  • 3
  • 15
  • 31
Omer
  • 19
  • 3
  • 3
    This is very basic if you don't mind me saying. But `desired_list = list[0].split(", ")` – alani Oct 08 '20 at 07:28
  • 2
    Does this answer your question? [How to convert comma-delimited string to list in Python?](https://stackoverflow.com/questions/7844118/how-to-convert-comma-delimited-string-to-list-in-python) – Or Y Oct 08 '20 at 07:32
  • Thanks you all. yes after another 5 min of searching I found the answer on google. Sorry - Will look a little deeper next time – Omer Oct 08 '20 at 07:42

1 Answers1

1
>>> listObj = ['05-19.scl, 05-22.scl, 05-24.scl, 06-41.scl']
>>> a = [x.split(',') for  x in listObj][0]
>>> a
['05-19.scl', ' 05-22.scl', ' 05-24.scl', ' 06-41.scl']
Surya Tej
  • 1,342
  • 2
  • 15
  • 25