How to append a string to a list in Python
Append is one of the most essential operations for any data structure, and lists are no exception. This operation adds an element at the end of the list.
In python, lists can be extended (appended) by using the append() method or by using “+=” operator. Here’s how to do it:
# Using append() method
list1 = ['a', 'b', 'c']
list1.append('d') # Now list1 is ['a', 'b', 'c', 'd'].
# Using "+=" operator
list2 = ['e', 'f', 'g']
list2 += ['h'] # Now list2 is ['e', 'f', 'g', 'h'].
Lists in Python are mutable. This means that once a list has been created, we can add or remove elements from it. The append() method adds an element to the end of the list and extend() method extends the list by adding multiple elements. You can also use “+=” operator for appending multiple values:
list1 = ['a', 'b', 'c']
list1.append('d')
print(list1) # Outputs: ['a', 'b', 'c', 'd']
list2 = ['e', 'f', 'g']
list2 += ['h']
print(list2) # Outputs: ['e', 'f', 'g', 'h']

AI Is Changing Software Development. This Is How Pros Use It.
Written for working developers, Coding with AI goes beyond hype to show how AI fits into real production workflows. Learn how to integrate AI into Python projects, avoid hallucinations, refactor safely, generate tests and docs, and reclaim hours of development time—using techniques tested in real-world projects.
