Built-In Methods On List
Built-In Methods On List
1.append()
The append() method is used to add an item to the
end of the list. It modifies the original list.
Syntax:
list name .append(element)
Example:
my_list=[1,2,3]
my_list.append(4)
print(my_list)
Output:
[1, 2, 3, 4]
2. clear()
3. copy()
Syntax:
new_list = list.copy()
Example:
my_list=[1,2,3]
new_list=my_list.copy()
new_list.append(4)
print('OriginalList:',my_list)
print('Copied List:', new_list)
Output:
OriginalList:[1,2,3]
Copied List: [1, 2, 3, 4]
4. count()