Converting a String to List in Python

django, python, string

Solution

Use the `split` method. Example:

>>> "0,1,2".split(",")
['0', '1', '2']

Or even,

>>> [int(x) for x in "0,1,2".split(",")]
[0, 1, 2]

Problem

I'm trying to create a list from arguments I receive in a url. e.g I have: ``` user.com/?users=0,1,2 ``` Now when I receive it in the request it comes as a string. I want to make a list out of "0,1,2" [0,1,2]

Original source