ZIP function in python | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 7

ZIP function in python

I have seen a piece of code somewhere and i don't understand the function of "*" in a line. The line was like this : List = [ list (x) for x in zip (*my_list)] my_list here is a 2-D list Help me plz

18th Jan 2018, 8:16 PM
Mr. Bot
Mr. Bot - avatar
5 Answers
+ 6
* takes the list's elements, and kind of "joins" them. For string lists, it's like "".join(list).
18th Jan 2018, 8:38 PM
LunarCoffee
LunarCoffee - avatar
+ 5
can you give an example ....
19th Jan 2018, 4:19 AM
Mr. Bot
Mr. Bot - avatar
+ 5
ls = ["a", "b", "c"] print(*ls) OUTPUT: abc
21st Jan 2018, 4:39 AM
LunarCoffee
LunarCoffee - avatar
30th Jan 2018, 2:08 AM
Satwik Dondapati
Satwik Dondapati - avatar
+ 2
The zip() function take iterables (can be zero or more), makes iterator that aggregates elements based on the iterables passed, and returns an iterator of tuples.
30th Jan 2018, 2:02 AM
Satwik Dondapati
Satwik Dondapati - avatar