import numpy as np    
a = np.arange(72)
a = np.reshape(a, (4,3,2,3))

or:

a = np.array([[[[1,2,3],[4,5,6]],[[7,8,9],[10,11,12]],[[13,14,15],[16,17,18]]], [[[1,2,3],[4,5,6]],[[7,8,9],[10,11,12]],[[13,14,15],[16,17,18]]], [[[1,2,3],[4,5,6]],[[7,8,9],[10,11,12]],[[13,14,15],[16,17,18]]], [[[1,2,3],[4,5,6]],[[7,8,9],[10,11,12]],[[13,14,15],[16,17,18]]]])

or:

a = np.array([[[1,2,3],[4,5,6]],[[7,8,9],[10,11,12]],[[13,14,15],[16,17,18]]])
a = np.expand_dims(a, axis=0)
a = np.repeat(a, 4, axis=0)
Answer from Sơn Ninh on Stack Overflow
🌐
Python
docs.python.org › 3 › library › array.html
array — Efficient arrays of numeric values — Python 3.15.2 documentation
1 month ago - This module defines an object type which can compactly represent an array of basic values: characters, integers, floating-point numbers, complex numbers. Arrays are mutable sequence types and behave very much like lists, except that the type ...
Discussions

Can I create an array where each field has 4 values?
Use a list of named tuples. https://docs.python.org/3/tutorial/datastructures.html https://docs.python.org/3/library/collections.html Actually, you can use a regular tuple, but accessing the data by name is pretty convenient. More on reddit.com
🌐 r/learnpython
8
16
August 3, 2021
python - How do I create a custom 4x4 array using NumPy? - Stack Overflow
I am new to Python and I am having a bit of trouble with the array functions. I want to make a 4 by 4 array which contains the numbers from 1 to 16. I know that using np.zeros((4,4)) outputs a 4x4 More on stackoverflow.com
🌐 stackoverflow.com
arrays - What does {:4} mean in this matrix printing solution in python? - Stack Overflow
In the solution to the question proposed here printing a two dimensional array in python I'm not able to figure out what the {:4} part of the solution means exactly. I've tried this print statement... More on stackoverflow.com
🌐 stackoverflow.com
Making a 4x4 array in python - Stack Overflow
I am trying to create a 4x4 array looking something like this:This is a javascript code that I'm trying to create into python More on stackoverflow.com
🌐 stackoverflow.com
🌐
W3Schools
w3schools.com › python › python_arrays.asp
Python Arrays
Note: Python does not have built-in support for Arrays, but Python Lists can be used instead.
🌐
GeeksforGeeks
geeksforgeeks.org › python › python-arrays
Python Arrays - GeeksforGeeks
1 array('i', [1, 2, 3, 5]) Explanation: parameter 'i' is the typecode, it tells Python to treat the elements as signed integers ([1, 2, 3]) of a specific byte size (usually 2 or 4 bytes). The following table outlines standard typecodes, their mapped C types and minimum memory requirements: Array can be created by importing an array module.
Published: September 19, 2026
🌐
Programiz
programiz.com › python-programming › array
Python Array of Numeric Values
March 26, 2024 - Note: When people say arrays in Python, more often than not, they are talking about Python lists. If that's the case, visit the Python list tutorial. To create an array of numeric values, we need to import the array module. For example: import array as arr a = arr.array('d', [1.1, 3.5, 4.5]) print(a)
🌐
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 NumPy library has a large set of routines for creating, manipulating, and transforming NumPy arrays. NumPy functions, like sqrt and sin, are designed specifically to work with NumPy arrays. Core Python has an array data structure, but it’s not nearly as versatile, efficient, or useful as the NumPy array.
Find elsewhere
🌐
AskPython
askpython.com › python › array › python-array-examples
Python Array - 13 Examples - AskPython
September 5, 2019 - import array # creating array int_array = array.array('i', [1, 2, 3, 4]) float_array = array.array('f', [1.1, 2.2, 3.3, 4.4]) # unicode array support is deprecated and will be deleted in Python 4 unicode_array = array.array('u', ['\u0394', '\u2167', '\u007B'])
🌐
AskPython
askpython.com › python › array › multidimensional-arrays
Multidimensional Arrays in Python: A Complete Guide - AskPython
February 27, 2023 - A simple way to define a 4D array is that it’s an array of 3D arrays. It is a bit complicated to visualize a 4D array but we can say that it’s a set of 3D arrays (like a row of cubes).
🌐
Quora
quora.com › How-do-you-create-a-4-dimensional-array-in-Python
How to create a 4-dimensional array in Python - Quora
Answer (1 of 3): There’s numpy of course which has multi-dimensional arrays, but if you insist on doing it yourself read on. One thing you can do is us a dictionary where the key is a tuple of indices and the value is the value at the cell. You can wrap this in a class that and have default ...
🌐
Real Python
realpython.com › python-array
Python's Array: Working With Numeric Data Efficiently – Real Python
May 13, 2026 - >>> fibonacci_numbers[2:9:3] = array("I", [3, 13, 55, 233]) Traceback (most recent call last): ... ValueError: attempt to assign array of size 4 to extended slice of size 3 · As with any sequence, you must ensure that the replacement slice has the same length as the one that you’re replacing when you use the extended syntax. That’s because the extra elements would produce gaps in your sequence, which must remain contiguous. On the other hand, regular slices with a step equal to one don’t have such a limitation. Note: Check out Python’s Mutable vs Immutable Types to learn more about the differences between both kinds of data types.
🌐
Real Python
realpython.com › ref › stdlib › array
array | Python Standard Library – Real Python
The Python array module provides an efficient data structure for creating arrays of values (often numbers), which are stored more compactly than in standard lists.
🌐
w3resource
w3resource.com › python-exercises › array
Python: Array - Exercises, Practice, Solution - w3resource
July 5, 2025 - Write a Python program to get the length in bytes of one array item in the internal representation. Sample Output: Original array: array('i', [1, 3, 5, 7, 9]) Length in bytes of one array item: 4 Click me to see the sample solution
🌐
Mimo
mimo.org › glossary › python › arrays
Python Arrays: Syntax, Usage, and Examples
Python · Open in MimoOpen in MimoCopy Code · import array nums = array.array('i', [1, 2, 3, 4]) 'i' is the type code for integers. This method uses less memory but requires elements to be the same type. Arrays are great for keeping track of related data items: Python ·
🌐
Stack Overflow
stackoverflow.com › questions › 68716275 › making-a-4x4-array-in-python
Making a 4x4 array in python - Stack Overflow
import numpy as np height, width = 4, 4 num = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15] array = np.array(num).reshape((height, width)) print(array)
🌐
Princeton University
introcs.cs.princeton.edu › python › 14array
Arrays in Python
In its most basic form, an array supports four core operations: creation, indexed access, indexed assignment, and iteration. In this booksite, we use Python's built-in list data type for arrays because it supports these basic operations. We consider more elaborate operations supported by Python's ...
🌐
Nanyang Technological University
libguides.ntu.edu.sg › python › arrayslicing
NP.4 Array Slicing - Python for Basic Data Analysis - LibGuides at Nanyang Technological University
August 26, 2026 - Learn practical Python programming skills for basic data manipulation and analysis. ... Array slicing is similar to list slicing in Python. Array indexing also begins from 0. However, since arrays can be multidimensional, we have to specify the slice for each dimension.
🌐
Great Learning
mygreatlearning.com › blog › it/software development › python array & how to use them [with examples]
Python Array & How To Use Them [With Examples]
March 26, 2026 - Arrays constitute the most efficient data storage approach when you work with numerical information. The built-in Python lists have specific use cases where arrays provided through the array module along with NumPy libraries demonstrate superior ...