Actually, none of the proposed solutions worked in my case (Python 2.7.6, NumPy 1.8.2). But I've found out, that change of dtype from complex (standard Python library) to numpy.complex_ may help:

>>> import numpy as np
>>> x = 1 + 2 * 1j
>>> C = np.zeros((2,2),dtype=np.complex_)
>>> C
array([[ 0.+0.j,  0.+0.j],
       [ 0.+0.j,  0.+0.j]])
>>> C[0,0] = 1+1j + x
>>> C
array([[ 2.+3.j,  0.+0.j],
       [ 0.+0.j,  0.+0.j]])
Answer from Lenka42 on Stack Overflow
🌐
Python.org
discuss.python.org › ideas
Complex numbers support in array module - Ideas - Discussions on Python.org
March 7, 2023 - I know about numpy, but I would really like to see it in the built-in python module, but I was wondering if this could be a thing. Any thoughts about this?
🌐
IncludeHelp
includehelp.com › python › numpy-creating-a-complex-array-from-2-real-ones.aspx
Python - NumPy: Creating a complex array from 2 real ones?
# Import numpy import numpy as np # Import pandas import pandas as pd # Creating two numpy arrays arr1 = np.array([15, 25, 30]) arr2 = np.array([5, 15, 20]) # Display original arrays print("Original array 1:\n",arr1,"\n") print("Original array 2:\n",arr2,"\n") # Creating a complex array com = np.empty((3,3),dtype=np.complex128) com.real = arr1 com.imag = arr2 # Display result print("Result:\n",com)
🌐
NumPy
numpy.org › doc › stable › reference › generated › numpy.array.html
numpy.array — NumPy v2.4 Manual
>>> np.array([1, 2, 3], dtype=complex) array([ 1.+0.j, 2.+0.j, 3.+0.j]) Data-type consisting of more than one element: >>> x = np.array([(1,2),(3,4)],dtype=[('a','<i4'),('b','<i4')]) >>> x['a'] array([1, 3], dtype=int32) Creating an array from sub-classes: >>> np.array(np.asmatrix('1 2; 3 4')) array([[1, 2], [3, 4]]) >>> np.array(np.asmatrix('1 2; 3 4'), subok=True) matrix([[1, 2], [3, 4]]) Limiting the maximum dimensions with ndmax: >>> a = np.array([[1, 2], [3, 4]], dtype=object, ndmax=2) >>> a array([[1, 2], [3, 4]], dtype=object) >>> a.shape (2, 2) >>> b = np.array([[1, 2], [3, 4]], dtype=object, ndmax=1) >>> b array([list([1, 2]), list([3, 4])], dtype=object) >>> b.shape (2,) Go BackOpen In Tab ·
🌐
GitHub
github.com › numpy › numpy › issues › 16039
Efficient way to create a complex array from two real arrays · Issue #16039 · numpy/numpy
April 22, 2020 - Dear NumPy developers, This may be more like a question. I have two real arrays (a and b), and I would like create a complex array (c) which takes the two real arrays as its real and imaginary parts respectively. The simplest one would b...
Author   zhcui
Top answer
1 of 3
1

You can think about it as each list within a list being a separate item. Whatever is in the list is irrelevant until you access it.

For your example:

place = ["high up", [...]]

place[0] is "high up" because the first item in place is that string.

complex_list = [[...], 42]

complex_list[0] is the whole list except 42 because the list is the first item.

2 of 3
0

Hope this helps you understand nesting a bit better:

a = ['this element is in outer list', #index No. [0]
     ['this is inner list', #index No. [1] to get whole list and index No. [1][0] to get 1st element
          ['this is inner list within inner list', #index No. [1][1] will get you list and No. [1][1][0] will get 1st element
               ['this is inner list within inner list that is within inner list']]], #index No. [1][1][1]
     'this element is in outer list', #index No. [2]
     ['this is inner list'], #index No. [3] if you want that list and index No. [3][0] to get string
     'this element is in outer list'] #index No. [4]

print a[0] #this element is in outer list
print a[1] #['this is inner list', ['this is inner list within inner list', ['this is inner list within inner list that is within inner list']]]
print a[1][0] #this is inner list
print a[1][1] #['this is inner list within inner list', ['this is inner list within inner list that is within inner list']]
print a[1][1][0] #this is inner list within inner list
print a[1][1][1] #['this is inner list within inner list that is within inner list']
print a[2] #this element is in outer list
print a[3] #['this is inner list']
print a[3][0] #this is inner list
print a[4] #this element is in outer list

Furthermore, you can access strings as if they are lists therefore if you have:

b = 'Example'
print b[0] #this will print E
print b[1] #this will print x
Find elsewhere
🌐
SciPy
docs.scipy.org › doc › › numpy-1.13.0 › reference › generated › numpy.array.html
numpy.array — NumPy v1.13 Manual
>>> np.array([1, 2, 3], dtype=complex) array([ 1.+0.j, 2.+0.j, 3.+0.j]) Data-type consisting of more than one element: >>> x = np.array([(1,2),(3,4)],dtype=[('a','<i4'),('b','<i4')]) >>> x['a'] array([1, 3]) Creating an array from sub-classes: >>> np.array(np.mat('1 2; 3 4')) array([[1, 2], [3, 4]]) >>> np.array(np.mat('1 2; 3 4'), subok=True) matrix([[1, 2], [3, 4]]) numpy.full_like ·
🌐
woteq
woteq.com › home › how to create a numpy array of complex numbers
How to Create a NumPy Array of Complex Numbers - woteq ZONE
September 23, 2025 - This guide will walk you through the various methods to create NumPy arrays filled with complex numbers. Before we start, you need to have NumPy installed. If you haven’t already, you can install it using pip: ... The most straightforward way is to pass a list of Python complex numbers to the np....
🌐
Moonbooks
moonbooks.org › Articles › How-to-create-a-matrix-of-complex-numbers-in-python-using-numpy-
How to create a matrix of complex numbers in python using numpy ?
November 15, 2019 - Examples of how to create a matrix of complex numbers in python using numpy: Table of contents · Create a matrix of random numbers · Create a matrix of random numbers with 0+0j · Create a matrix of random complex numbers · References · >>> Z = np.array([[1+2j,1+3j],[5+6j,3+8j]]) >>> Z array([[ 1.+2.j, 1.+3.j], [ 5.+6.j, 3.+8.j]]) >>> import numpy as np >>> Z = np.zeros(10, dtype=complex) >>> Z array([ 0.+0.j, 0.+0.j, 0.+0.j, 0.+0.j, 0.+0.j, 0.+0.j, 0.+0.j, 0.+0.j, 0.+0.j, 0.+0.j]) Another example ·
🌐
GeeksforGeeks
geeksforgeeks.org › extracting-the-real-and-imaginary-parts-of-an-numpy-array-of-complex-numbers
Extracting the real and imaginary parts of an NumPy array of complex numbers - GeeksforGeeks
September 2, 2020 - ExampleInput: [ -1. -2. nan 1000.] Output: 1000.0 Explanation: maximum value of the array ignoring nans. One approach to use the built-in Python function max(), along with the ... Introduction to python complex numbers: Complex Numbers in Python | Set 1 (Introduction) Some more important functions and constants are discussed in this article.
🌐
w3resource
w3resource.com › python-exercises › numpy › python-numpy-exercise-15.php
NumPy: Find the real and imaginary parts of an array of complex numbers - w3resource
August 29, 2025 - Write a NumPy program to find the real and imaginary parts of an array of complex numbers · Sample Solution: Python Code: # Importing the NumPy library with an alias 'np' import numpy as np # Calculating square root of a complex number x = np.sqrt([1 + 0j]) # Calculating square root of another complex number y = np.sqrt([0 + 1j]) # Printing the original array 'x' and 'y' print("Original array:x ", x) print("Original array:y ", y) # Printing the real part of the array 'x' and 'y' print("Real part of the array:") print(x.real) print(y.real) # Printing the imaginary part of the array 'x' and 'y'
🌐
DigitalOcean
digitalocean.com › community › tutorials › python-convert-numpy-array-to-list
Convert NumPy Array to List in Python Easily | DigitalOcean
April 19, 2025 - As you can see, the tolist() method has successfully converted the complex, nested array with mixed types to a list, preserving the original structure and handling the mixed types correctly.
🌐
Medium
medium.com › @whyamit404 › working-with-complex-numbers-in-numpy-c3eae8876a88
Working with Complex Numbers in NumPy | by whyamit404 | Medium
February 8, 2025 - So, how do you create complex numbers? It’s simple. You can use numpy.array() to create an array of complex numbers, just like any other NumPy array.