How to Make an Array of Strings in Python

To create a list of empty strings in Python, use a for loop and add empty strings to the list using the .append() function.

 

strings = []

for i in range(4):
   strings.append('')
   
print(strings)
['', '', '', '']

 

Adjust the number of string to add to the array by adjusting the value of range().

 

With List Comprehension

It is possible to create a list of empty strings in one line by using list comprehension.

 

strings = ["" for i in range(4)]

print(strings)
['', '', '', '']
string array list