Answer the question
In order to leave comments, you need to log in
How to convert a list of numbers to a list of complex numbers in Python?
Given a list for example: data=[4,5,7,8,9,0,3,3,6,6]
it contains 5 complex numbers (re1,im1,re2,im2,re3,im3....)
how to make from this list, a list with complex numbers?
something like this data=[(4+5j),(7+8j),...]
Answer the question
In order to leave comments, you need to log in
data=[4, 5, 7, 8, 9, 0, 3, 3, 6, 6]
c = [complex(a, b) for a, b in zip(data[:-1:2], data[1::2])]
print(c)
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question