B
B
Brutus12020-07-20 11:58:16
Python
Brutus1, 2020-07-20 11:58:16

How to make a list from a string?

There is a line how to make a list out of it: so that it can be iterated.
hashes_string = "['1','2','3']"

hashes = ['1','2','3']

Answer the question

In order to leave comments, you need to log in

2 answer(s)
D
Dr. Bacon, 2020-07-20
@Brutus1

ast.literal_evalBut here the question is different, where did such a line come from, maybe you are doing something wrong?

N
noremorse_ru, 2020-07-20
@noremorse_ru

[x for x in "['1','2','3']" if x.isdigit()]

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question