1

I was wondering how I could change a list written as a string, such as ‘[1,[2,[]],[3,[]]]’ into an actual python list like [1,[2,[]],[3,[]]]. Is there any algorithm for this?

Saikat1529
  • 156
  • 12

2 Answers2

-1

This topic have a lot of examples of solutions for your problem :)

Python - convert string to list

Regards,

-2

Assign your value to a variable then call the variable.split() it defaults to comma delimited which in your instance would result in list['[1,[2,[]],[3,[]]]']

another example of this could be this:

a = "test, 1, testing2, alpha, beta, Zulu, 23"
a.split()
Result: ['test,', '1,', 'testing2,', 'alpha,', 'beta,', 'Zulu,', '23']
  • sorry I forgot that split is default space delimited if you do a.split(",") you end up with a comma delimited python list – Mike Pineau Dec 04 '17 at 19:34