'[1, 2]'
It is a string. How to I make it List [1,2]
So convertion from '[1, 2]'
to [1,2]
'[1, 2]'
It is a string. How to I make it List [1,2]
So convertion from '[1, 2]'
to [1,2]
You have a couple of options
eval('[1, 2]')
# [1, 2]
import ast
ast.literal_eval('[1, 2]')
# [1, 2]
string parsing
list(map(int, '[1, 2]'.strip('[]').split(', ')))
# [1, 2]