How To Add To A List In Python?

Use `my_list.append(item)` to add one item to the end of a list

Use `my_list.extend([item1, item2])` to add multiple items to the end of a list

Use `my_list.insert(index, item)` to add an item at a specific position

Use `my_list += [item1, item2]` to add multiple items to a list

Use `my_list[len(my_list):] = [item]` to add items at the end

Use `my_list = my_list + [item]` to create a new list with added items

Suggested for You

Trending Today