[[+content_image]]
G
G
ghostku2015-10-08 18:02:53
Python
ghostku, 2015-10-08 18:02:53

How to merge lists in Python?

there are several lists, for example:

a = ['Petr','Ivan','Sydor']
b = ['Petrov','Ivanov','Sydorov']
c = ['23','24','25']

from them you need to get a list of the form:
x = [['Petr','Petrov','23'],['Ivan','Ivanov','24'],['Sydor','Sydorov','25']]

I feel that in Python there should be some kind of elegant construction for this, but I can’t figure out how to correctly formulate the question in Google
Thanks

Answer the question

In order to leave comments, you need to log in

[[+comments_count]] answer(s)
T
tsarevfs, 2015-10-08
@ghostku

zip(a, b, c)
[list(l) for l in zip(a, b, c)] #если нужны именно листы внутри

G
Gasoid, 2015-10-08
@Gasoid

x = [a, b, c]
or

x = []
x.append(a)
x.append(b)
x.append(c)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question