If I type:
>>> list(str([0, 0, 0]))
I get:
['[', '0', ',', ' ', '0', ',', ' ', '0', ']']
How would I make it so that I get [0, 0, 0]
instead?
If I type:
>>> list(str([0, 0, 0]))
I get:
['[', '0', ',', ' ', '0', ',', ' ', '0', ']']
How would I make it so that I get [0, 0, 0]
instead?
If what you want to do is cast every item into a string. Do this:
>>> orig_list = [0, 0, 0]
>>> new_list = [str(item) for item in orig_list]
>>> new_list
['0', '0', '0']
It is not a good idea to use in a production code but you can use
eval("".join(list(str([0, 0, 0]))))
You can use list comprehension like this:
my_str = str([0, 0, 0])
my_list = [int(s) for s in my_str.replace('[', '').replace(']', '').split(',')]
Now you have:
>>> my_str
'[0, 0, 0]'
>>> my_list
[0, 0, 0]