Member-only story
How to Work With List of Strings in Python | Python Tutorial
Includes list of strings as examples
In Python, a list of strings is a type of list that contains strings as elements.
From time to time, Python programmers need to work with a list of strings.
As developers, we need to create a list of strings and add new strings to the list.
Sometimes we need to sort the list of strings and concatenate a list of strings.
Here we will look at different operations that can be performed on a list of strings.
1. How to create a list of strings
If you want to create a list of strings, you have to use the square brackets.
The square brackets [
and ]
will help you create a list.
Once you’ve used brackets, write the list of items inside the brackets.
You must separate the elements within the list with commas.
Don’t forget to add quotes when you write the string elements inside the brackets.
To store the list in a variable, you must use the =
operator.
list_of_strings = ["hello" , "hey" , "how"]print(list_of_strings)