Q: Adding content to list I have the following code:
list = []
content = "1, 1, 1, 2, 3, 1"

How do I add the content to the list?
Feels like a very silly question, but I don't manage.
UPDATE:
Thanks, the split-command did the work. Solved!

A: you can use .append()
list.append(content)


A: Since content is just a string, you can just split and turn it into a list.
myList = content.split(",")
Also, don't name your list list, because list is a reserved keyword in Python and will likely cause problems.
edit: it's not a reserved keyword, it's a reserved type as pointed out by inof in the comment below. Still bad practice to use it for a variable name.

A: Assuming that you want to split the string and add the elements as integers (which makes the most sense), this will do it:
mylist = []
mylist += [int(i) for i in content.split(",")]

Note that it is not a good idea to name your list list, because that is already the name of the built-in type.
Of course, if the list is empty to begin with (according to your code), you can initialize it in one step without having to assign an empty list first:
mylist = [int(i) for i in content.split(",")]


A: Few possible ways -

*

*list of strings -

my_list = []
content = "1, 1, 1, 2, 3, 1"

#if you want string.
my_list = content.split(',') 



*list of int


# if int(list comprehension)
my_list = [int(s) for s in content.split(',')]

# if int(via map)
my_list = list(map(int,content.split(',')))

Note -> 2nd case may throw an error if initial string contains contains non_numeric characters -
ValueError: invalid literal for int() with base 10: 'some_char'
