Add value to a list Python code example
Example 1: add something to list python
lst = [1, 2, 3]
something = 4
lst.append(something)
Example 2: add item to list python
list.append(item)
Example 3: append to lists python
list = ['larry', 'curly', 'moe']
list.append('shemp')
list.insert(0, 'xxx')
list.extend(['yyy', 'zzz'])
print list
print list.index('curly')
list.remove('curly')
list.pop(1)
print list
Example 4: how to add a value to a list in python
myList = [apples, grapes]
fruit = input()
myList.append(fruit)
Example 5: how to add element in list
list = []
list.append(var)