Contents
Create a list of strings
To create a list of strings in Python, you can create an empty list and add string elements to the list, or initialise the list with just string elements.
Examples
1. Create empty list and add string elements
In the following program we create an empty list x
and add string elements to this list using append() function.
Python Program
x = []
x.append('apple')
x.append('banana')
x.append('cherry')
print(x)
Run Output
['apple', 'banana', 'cherry']
2. Initialize list with string elements
In the following program we create a list x
and initialised it with string elements.
Python Program
x = ['apple', 'banana', 'cherry']
print(x)
Run Output
['apple', 'banana', 'cherry']
Summary
In this tutorial of Python Examples, we learned how to create a list with string elements, with the help of examples.
Related Tutorials
- How to Access List Items in Python?
- Python Program to Find Unique Items of a List
- Python List of Dictionaries
- How to Append List to Another List in Python? – list.extend(list)
- Python List of Functions
- How to Check if Python List is Empty?
- Python List of Lists
- Python – Check if List Contains all Elements of Another List
- Python Program to Find Smallest Number in List
- Python List – Add Item