append numbers to a list python code example

Example 1: add item to list python

list.append(item)

Example 2: append to list python

list = ["a"]
list.append("b")

print(list)
["a","b"]

Example 3: how to append to a list of lists in python

list_of_Lists = [[1,2,3],['hello','world'],[True,False,None]]
list_of_Lists.append([1,'hello',True])
ouput = [[1, 2, 3], ['hello', 'world'], [True, False, None], [1, 'hello', True]]

Example 4: append a list to another list as element

a = ['Jon', 'janni', 'Jannardhan']
b = ['28', '29', '30']
a.append(b)
print(a)
a.pop()
a.extend(b)
print(a)

Tags:

Misc Example