If you fix the lenght of the array, you can just create a list with a none value

keyword = [''] * 100   # list of 100 element
keyword[0] = 'Blue Light Glasses'
keyword[1] = "Tech Fleece Joggers"

You can also create a empty list and add element in this list

keyword = list()
keyword.append('Blue Light Glasses')
keyword.append('Tech Fleece Joggers')
print(keyword)

Output:

['Blue Light Glasses', 'Tech Fleece Joggers']
Answer from Shrmn on Stack Overflow
Top answer
1 of 2
3

If you fix the lenght of the array, you can just create a list with a none value

keyword = [''] * 100   # list of 100 element
keyword[0] = 'Blue Light Glasses'
keyword[1] = "Tech Fleece Joggers"

You can also create a empty list and add element in this list

keyword = list()
keyword.append('Blue Light Glasses')
keyword.append('Tech Fleece Joggers')
print(keyword)

Output:

['Blue Light Glasses', 'Tech Fleece Joggers']
2 of 2
0

there isn't a way in python to declare a array of a fixed lenght but there are some "tricks" to do this as:

lenght = 100
# You are creating an array of 100 None items
listOfNone = [None] * lenght

Another thing you can't do is declare an array of that fixed value type (like string). You can create an array only made of string but at any time you could replace a string element of the array with an int for example. Here is an example:

lenght = 100
# Declaring an array made of 100 "a beautiful string" repeating
listOfStrings = ["a beautiful string"] * lenght 
# Replacing the tenth element with a 12 (type int)
listOfStrings[9] = 12
# You can check the type of the element in python by printing:
print(type(listOfStrings[9])) # This will print int
print(type(listOfStrings[8])) # This will print string. As you can see there are 2 types of var in the same list (python doesn't matter)
listOfStrings[24] = False #Placing a bool in the 25th element

There is a workaround to this: you can create a function that handles the array (or use a class too, but I don't know your Python level). I'm typing a basic function for you that you can adjust for your needs

def fillArrayWithElement(array, element):
    if not str(type(array)) == "<class 'list'>":
        # The array is not an array
        raise ValueError('The first parameter must be list type')
        return
    if not str(type(prova2)) == "<class 'str'>":
        # The element to add is not a string
        raise ValueError('The element must be str type')
        return
    array.append(element)
    return array
🌐
W3Schools
w3schools.com › python › python_arrays.asp
Python Arrays
Remove List Duplicates Reverse a String Add Two Numbers · Python Examples Python Compiler Python Exercises Python Quiz Python Challenges Python Server Python Syllabus Python Study Plan Python Interview Q&A Python Bootcamp Python Certificate Python Training ... Note: Python does not have built-in support for Arrays, but Python Lists can be used instead.
Discussions

Can't get string array to print
I am trying to loop through an array of strings and get it to print but I keep getting this error: TypeError: an integer is required (got type str) This is what I have so far because I erased everything else I had written. from array import * days = array(‘B’, [‘Monday’, ‘Tuesday’, ... More on forum.freecodecamp.org
🌐 forum.freecodecamp.org
1
June 22, 2018
How do I convert Numpy Array to a List of Strings?
what is x ? Can you share small snippet of your code? More on reddit.com
🌐 r/learnpython
6
1
December 2, 2020
Just a little pixelart to python array of strings converter I made this weekend, so you can display your pixelarts in the python's command line interface
Hey, that’s pretty cool. Do you plan on uploading it on github? More on reddit.com
🌐 r/Python
40
732
January 23, 2019
How to decode a numpy array of encoded literals/strings in Python3?
(That is, I don't want b'') Why not? It shouldn't bother anything. However, if you really want to, use astype(): array1 = array1.astype(str) More on reddit.com
🌐 r/learnpython
14
1
November 2, 2016
🌐
GeeksforGeeks
geeksforgeeks.org › python › how-to-create-string-array-in-python
How to Create String Array in Python ? - GeeksforGeeks
July 23, 2025 - Later on an element can be added or removed from this array. ... Numpy module in Python is used for working with array. Using the numpy module's array() function, a string array can be created easily.
🌐
Awkward-array
awkward-array.org › doc › main › user-guide › how-to-create-strings.html
How to create arrays of strings — Awkward Array 2.9.0 documentation
['three', 'one', 'two', 'two', 'three', 'one', 'one', 'one'] --------- backend: cpu nbytes: 107 B type: 8 * categorical[type=string] Internally, the data now have an index that selects from a set of unique strings.
🌐
Spark By {Examples}
sparkbyexamples.com › home › python › how to create array of strings in python
How to Create Array of Strings in Python - Spark By {Examples}
December 20, 2024 - There is no built-in array data structure in Python specifically for storing strings. However, you can use a list to create an array of strings. First, create an empty array and then add stings to the array using the append() function.
🌐
NumPy
numpy.org › devdocs › user › basics.strings.html
Working with Arrays of Strings And Bytes — NumPy v2.5.dev0 Manual
Working with data loaded or memory-mapped from a data file, where one or more of the fields in the data is a string or bytestring, and the maximum length of the field is known ahead of time. This often is used for a name or label field. Using NumPy indexing and broadcasting with arrays of Python strings of unknown length, which may or may not have data defined for every value.
Find elsewhere
🌐
W3Schools
w3schools.com › python › gloss_python_strings_are_arrays.asp
Python Strings Are Arrays
Like many other popular programming languages, strings in Python are arrays of bytes representing unicode characters.
🌐
PragmaticLinux
pragmaticlinux.com › home › how to create an array of strings in python
How to create an array of strings in Python - PragmaticLinux
September 27, 2022 - This article explains how to create an array of strings in Python, including code examples for iterating over the string array.
🌐
Python
docs.python.org › 3 › library › array.html
array — Efficient arrays of numeric values
Read n items (as machine values) from the file object f and append them to the end of the array. If less than n items are available, EOFError is raised, but the items that were available are still inserted into the array. ... Append items from the list. This is equivalent to for x in list: a.append(x) except that if there is a type error, the array is unchanged. ... Extends this array with data from the given Unicode string.
🌐
Python documentation
docs.python.org › 3 › library › stdtypes.html
Built-in Types — Python 3.14.3 documentation
1 week ago - Some operations are supported by several object types; in particular, practically all objects can be compared for equality, tested for truth value, and converted to a string (with the repr() function or the slightly different str() function). The latter function is implicitly used when an object is written by the print() function. Any object can be tested for truth value, for use in an if or while condition or as operand of the Boolean operations below.
🌐
freeCodeCamp
forum.freecodecamp.org › python
Can't get string array to print - Python - The freeCodeCamp Forum
June 22, 2018 - I am trying to loop through an array of strings and get it to print but I keep getting this error: TypeError: an integer is required (got type str) This is what I have so far because I erased everything else I had written. from array import * days = array(‘B’, [‘Monday’, ‘Tuesday’, ...
🌐
W3Schools
w3schools.com › python › numpy › numpy_data_types.asp
NumPy Data Types
The astype() function creates a copy of the array, and allows you to specify the data type as a parameter. The data type can be specified using a string, like 'f' for float, 'i' for integer etc.
🌐
freeCodeCamp
freecodecamp.org › news › python-split-string-how-to-split-a-string-into-a-list-or-array-in-python
Python Split String – How to Split a String into a List or Array in Python
April 4, 2023 - By Shittu Olumide In this article, we will walk through a comprehensive guide on how to split a string in Python and convert it into a list or array. We'll start by introducing the string data type in Python and explaining its properties. Then we'll...
🌐
GeeksforGeeks
geeksforgeeks.org › python › python-data-types
Python Data Types - GeeksforGeeks
Each assignment replaces previous value, making 'x' take on data type and value of most recent assignment. ... x = 50 # int x = 60.5 # float x = "Hello World" # string x = ["geeks", "for", "geeks"] # list x = ("geeks", "for", "geeks") # tuple · Python numbers represent data that has a numeric value.
Published   3 days ago
🌐
Pydantic
docs.pydantic.dev › latest › concepts › models
Models - Pydantic Validation
One common application of this functionality is integration with object-relational mappings (ORMs). This feature need to be manually enabled, either by setting the from_attributes configuration value, or by using the from_attributes parameter on model_validate(). The example here uses SQLAlchemy, but the same approach should work for any ORM. from typing import Annotated from sqlalchemy import ARRAY, String from sqlalchemy.orm import DeclarativeBase, Mapped, mapped_column from pydantic import BaseModel, ConfigDict, StringConstraints class Base(DeclarativeBase): pass class CompanyOrm(Base): __t
🌐
New York University
physics.nyu.edu › pine › pymanual › html › chap3 › chap3_arrays.html
3. Strings, Lists, Arrays, and Dictionaries — PyMan 0.9.31 documentation
The elements of lists and arrays are numbered consecutively, and to access an element of a list or an array, you simply refer to the number corresponding to its position in the sequence. The elements of dictionaries are accessed by “keys”, which can be either strings or (arbitrary) integers (in no particular order). Dictionaries are an important part of core Python.
🌐
Pandas
pandas.pydata.org › pandas-docs › stable › user_guide › indexing.html
Indexing and selecting data — pandas 3.0.1 documentation
.iloc is primarily integer position based (from 0 to length-1 of the axis), but may also be used with a boolean array. .iloc will raise IndexError if a requested indexer is out-of-bounds, except slice indexers which allow out-of-bounds indexing. (this conforms with Python/NumPy slice semantics).