-1

I have a string

s = '[ 1 , 2 , 3]'

how to create a list from s?

Padraic Cunningham
  • 176,452
  • 29
  • 245
  • 321
palazzo train
  • 3,229
  • 1
  • 19
  • 40

1 Answers1

2

You can use the json module:

import json
s = '[1, 2, 3]'
json_as_list = json.loads(s)
Chedy2149
  • 2,821
  • 4
  • 33
  • 56