What is the function of the append method in Python?
In Python, the append() function is used to add elements to a list. When append() is called, it will append the specified element to the end of the list. This function is a built-in method of lists and can be called using a list object. For example:
my_list = [1, 2, 3]
my_list.append(4)
print(my_list) # 输出: [1, 2, 3, 4]
As shown above, after calling the append() function, element 4 is added to the end of the list my_list.