Append() and insert() of Python learning

Python provides functions such as append() and insert() to realize the function of adding new elements to the list

1. The append() method appends an element to the end of a list. The basic syntax is as follows:

list.append(obj)

list: to be processed list
obj: to insert elements

2. The insert() method can insert elements at any specified position in the list. The basic syntax is:

list.insert(index,obj)

list: is the list to be processed
index: index, refers to the inserted position
obj: inserted element

Guess you like

Origin blog.csdn.net/baidu_24752135/article/details/111597955