Home > Article > Backend Development > What does add mean in python
The add() function in python can add the object as a whole to the dictionary. If the added element is already in the dictionary, no operation will be performed
1. add(element) function
treats the object as a whole and adds elements to the dictionary. If the added element is already in the dictionary, no operation will be performed
##Other ways to add elements
2. append(seq) function
3. The extend(seq) function
will All elements (N) are added to the end of the list one by one. After addition, the list elements are increased by N Usually, the iterable object is a list; when it is a string, each character is added to the end of the list one by one; when it is a dictionary, The dictionary keys are added to the end of the list. The function has no return value.
4. insert(index, obj) function
Invert the object As a whole, it is added to the specified position of the list. After addition, the list only adds 1 element. The method is similar to append()
Specially, when adding an element at the end of the list, the index is len(object) and the index is -1. Insert at the second to last position, not the end.
##Related learning recommendations:
The above is the detailed content of What does add mean in python. For more information, please follow other related articles on the PHP Chinese website!