T
Tim Couper
It looks like you have a string which starts and ends with square
brackets and is a repeated group of (integer, comma (and perhaps
space)). What you don't have is a "string with a list in it"
One solution:
s="[16, 16, 2, 16, 2, 16, 8, 16]"
mylist=[int(s.strip()) for s in s[1:-1].split(',')]
Tim
Dr Tim Couper
CTO, SciVisum Ltd
www.scivisum.co.uk
brackets and is a repeated group of (integer, comma (and perhaps
space)). What you don't have is a "string with a list in it"
One solution:
s="[16, 16, 2, 16, 2, 16, 8, 16]"
mylist=[int(s.strip()) for s in s[1:-1].split(',')]
Tim
Dr Tim Couper
CTO, SciVisum Ltd
www.scivisum.co.uk