How to zip with a list output in Python instead of a tuple output

0 votes
Hi all, pretty simple question. My requirement is that I want to know which is the most efficient way of obtaining a list of lists from a set of lists. Let us say I want a list from a set of 2 lists.

How do I go about doing this?

Check out the following input:

And this is what I would want:

Can we make use of maps instead of zip to achieve this? The problem is that I am unaware of any of the standard libraries that are present to suit my requirement.

I am aware that I can define my own function and make use of it as well.

All help appreciated!
Feb 7, 2019 in Python by Anirudh
• 2,090 points
1,770 views

1 answer to this question.

0 votes

Good question - Considering that you are actually zipping more than two lists, you can make use of the following syntax:

[list(a) for a in zip([1,2,3], [4,5,6], [7,8,9])]

What this basically does is that this makes use of the comprehensions of the list and ends up converting each of the element present in the tuple into lists as per your requirement.

Hope this helps!

answered Feb 7, 2019 by Nymeria
• 3,560 points

Related Questions In Python

0 votes
1 answer

How to get permutations of list or a set in Python?

Permutation is an arrangement of objects in ...READ MORE

answered Jul 11, 2019 in Python by Neel
• 3,020 points
8,901 views
0 votes
0 answers
0 votes
1 answer

How to get a list of built in modules in Python?

simply open the python shell and type ...READ MORE

answered Aug 1, 2019 in Python by Arvind
• 3,050 points
1,390 views
0 votes
1 answer

How to create a zip archive of a directory in Python?

Hello @kartik, The easiest way is to use shutil.make_archive. ...READ MORE

answered May 11, 2020 in Python by Niroj
• 82,840 points
639 views
0 votes
2 answers
+1 vote
2 answers

how can i count the items in a list?

Syntax :            list. count(value) Code: colors = ['red', 'green', ...READ MORE

answered Jul 7, 2019 in Python by Neha
• 330 points

edited Jul 8, 2019 by Kalgi 4,441 views
0 votes
1 answer
+5 votes
6 answers

Lowercase in Python

You can simply the built-in function in ...READ MORE

answered Apr 11, 2018 in Python by hemant
• 5,790 points
4,077 views
0 votes
1 answer

List comprehension on a nested list - How to do it in Python?

Not sure what your desired output is, ...READ MORE

answered Nov 21, 2018 in Python by Nymeria
• 3,560 points
1,521 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP