I am opening a .txt file and have to use a list inside of it for a function I am writing. This is one of the lists given in the text file:
.txt
\'[24, 72
you don't need to go importing anything for this
s = '[24, 72, 95, 100, 59, 80, 87]' s.translate(None, '[]').split(', ') will give you a list of numbers that are strings
s = '[24, 72, 95, 100, 59, 80, 87]'
s.translate(None, '[]').split(', ') will give you a list of numbers that are strings
if you want a list of ints try
[int(i) for i in s.translate(None, '[]').split(', ')]