-1

I have a string

s = '[ 1 , 2 , 3]'

how to create a list from s?

Padraic Cunningham
  • 160,756
  • 20
  • 201
  • 286
palazzo train
  • 2,657
  • 1
  • 13
  • 35

1 Answers1

2

You can use the json module:

import json
s = '[1, 2, 3]'
json_as_list = json.loads(s)
Chedy2149
  • 2,211
  • 3
  • 26
  • 47