append() – add an entry to the end of a list

Code Explanation

LineDescription
1Declaration and initialization of the list myList with the values 1, 2, 3, 4 and 5
2The append() method appends a new element to the list
4 + 5With the for loop each list element is output
myList = [1, 2, 3, 4, 5]
myList.append(6)

for i in myList:
    print(i, end=" ")
Output
1 2 3 4 5 6