Creating a list out of raw data like that in problem 15

Back to General discussions forum

ryancurtisacosta     2018-11-05 21:28:42

how do I convert a dataset that is not in list format easily? I can add [] and ,'s manually but that would take a long time. I should specify that this is for Python

Rodion (admin)     2018-11-06 04:56:41
User avatar

Hi there!

Your idea (adding commas and brackets manually) is not that bad if you do this with auto-replace feature in text editor (probably even "notepad" can substitute spaces with commas).

However you are right - there should be some "more programmatic" approach, like this:

  • read the whole line
  • split it by spaces
  • convert each fragment from string to int

Hope this helps. (find precise examples of each of three steps with google - this may be slightly different in two python versions)

Please login and solve 5 problems to be able to post at forum