How to add a string or multiple strings to a list in Python? Adding a string to a list is a widespread usage of list operation and it can be done in several ways. For example, you can use the + operator, append(), insert(), extend(), and list comprehension. In this article, I will explain adding string to a list in Python by using all these methods with examples.
Below are methods to add or append a string to a list in Python:
- Append String at the end of a list.
- Add an element at a specific index in a list.
- Add elements from the list to the end of the list.
- Use
+operator to concatenate two string lists together. - Use
list comprehensionto add string elements to a list.
1. Quick Examples of Adding String to a List
If you are in a hurry, below are some quick examples of adding a string to a list in Python.
# Quick examples of adding string to a list
# Example 1: Add string to list at the end
# Using append() function
technology = ['Spark','Python','Pyspark']
technology.append('Java')
# Example 2: Add list with string to the list
# Using append() function
technology1 = ['Hyperion', 'Pandas', 'Pyspark']
technology.append(technology1)
# Example 3: Add string at specific position
# Using insert() function
technology.insert(0, 'Hadoop')
# Example 4: Add string list by extending elements
# Using extend() function
technology1 = ['Pandas', 'Pyspark']
technology.extend(technology1)
# Example 5: Use the + operator
technology += technology1
# Example 6: Using list comprehension
result = technology + [x for x in technology1]
2. Add String to List at the End
By using append() you can add a string at the end of the list in Python. This method takes the string as an argument and adds the string to the existing list, this does not return any value. For example, let’s take list called technology and add the string Java using the following code.
# Consider list of strings
technology = ['Spark','Python','Pyspark']
print("Original list",technology)
# Add string to the list
technology.append('Java')
print("Updated list: ",technology)
Yields below output.

Similarly, you can also use the append() to add a list of strings to a list in Python. For example, create a list technology1 and add it to the list technology. Now technology contains the elements of the original list and the list you added.
# Create two lists
technology = ['Java', 'Spark', 'Python']
print("First list: ",technology)
technology1 = ['Hyperion', 'Pandas', 'Pyspark']
print("Second list: ",technology1)
# Add list and an element to list
# Using append()
technology.append(technology1)
print("Updated list:",technology)
This example yields the below output. Notice that the list is added as a single element resulting nested list.

3. Add String at a Specific Position
You can use the insert() to add a string at a specific index position in the Python list. This takes two parameters, first the index where you want to add and the string value to be added. Let’s add a string 'Hadoop' at the first position on the list. For more examples refer to add element to list by index.
# Add string at a specific position
technology = ['Spark','Python','Pyspark']
# Insert first position
technology.insert(0, 'Hadoop')
print(technology)
# Output:
# ['Hadoop', 'Spark', 'Python', 'Pyspark']
# Insert second position
technology = ['Spark','Python','Pyspark']
technology.insert(1, 'Hyperion')
print(technology)
# Output:
# ['Spark', 'Hyperion', 'Python', 'Pyspark']
4. Add Multiple Strings to the List
The extend() adds multiple strings to the existing list at the end. When you add an iterator with strings by using this method, it actually extends the strings as separate strings and adds them to the list. Note that this modifies the existing list with the new strings and the strings are added at the end of the original list. For more examples refer to append multiple elements to the list.
# Add Multiple Strings to the List
technology = ['Spark', 'Python']
technology1 = ['Pandas', 'Pyspark']
# Extend list to list
technology.extend(technology1)
print(technology)
# Output:
# ['Spark', 'Python', 'Pandas', 'Pyspark']
Let’s add a string from the tuple to insert into the list. Here, my list had 2 strings to start with, and added a tuple of 3 strings, after adding a tuple, there are 5 strings in the list.
# Consider the list of strings
technology = ['Spark', 'Python']
print("Actual List: ",technology)
# Extend tuple to list
technology.extend(('Java','Pandas','Pyspark'))
print("Final List: ",technology)
# Output:
# Actual List: ['Spark', 'Python']
# Final List: ['Spark', 'Python', 'Java', 'Pandas', 'Pyspark']
5. Add String to List Using + Operator
You can also use the "+" operator to concatenate two lists together. So, the += operator is effectively adding the elements of technology1 to the end of the technology list, modifying the original list in place. For example,
# Use the += operator
technology = ['Spark', 'Python']
technology1 = ['Pandas', 'Pyspark']
technology += technology1
print(technology)
# Output:
# ['Spark', 'Python', 'Pandas', 'Pyspark']
6. Using List Comprehension
You can use list comprehension to add a string to a list based on a certain condition or operation.
In the below example, the list comprehension [x for x in technology1] is used to create a new list containing the elements of technology1, and then the + operator is used to concatenate it with the technology list. So, the result list contains all the elements from both technology and technology1. Your usage of list comprehension in this case is concise and effective.
# Using list comprehension
result = technology + [x for x in technology1]
print(result)
Frequently Asked Questions On Add String to a List in Python
There are several ways to add a string to a list. Two common approaches are using the append() method and the + operator.
If you are looking for a more concise way to add a string to a list in Python, you can use the += operator. This is equivalent to using the my_list = my_list + [new_string] syntax but is more concise. The += operator modifies the original list in place by extending it with the elements from the provided iterable, in this case, a list containing the new string.
list comprehension can be used to add a string (or multiple strings) to a list in Python. For example, the list comprehension [item for item in my_list] creates a new list containing the elements from the existing list my_list, and then the + operator is used to concatenate it with a new list containing the new_string. The result is assigned back to my_list.
If you’re frequently adding elements to the end of a list, using append() is generally more efficient than the + operator or list comprehension, especially for large lists. List comprehension and + create new lists, which might involve copying elements.
It depends on the method used. The append() method and += operator modify the original list in place. The + operator creates a new list, so you need to reassign it to the original list.
Conclusion
This article explained how to add or append a string at the end of a Python list, add a string at a specific index in a list, and add multiple strings from the list at the end. Also explained using + operator to concatenate two string lists together and finally use the list comprehension.
Happy Learning !!
Related Articles
- Python List Mutable
- Python List Multiply
- Python List Operations
- Python List to Integer
- Python List Subtraction
- Python List Concatenation
- Python List max() Function
- Python List min() Function
- Python List clear() Method
- Python List Union with Example
- Python List of Tuples into Dictionary
- Python List Unpacking with Examples