+ 2

Transpose with zip

In this code "zip" is used to transpose "data" from a 4-by-3 matrix to a 3-by-4 matrix I don't know how it works please explain https://code.sololearn.com/c6CLsDss5xqe/?ref=app

25th Nov 2023, 10:51 AM
Amateur
8 Answers
+ 9
The zip() function returns a zip object, which is an iterator of tuples where the first item in each passed iterator is paired together, and then the second item in each passed iterator are paired together etc. If the passed iterables have different lengths, the iterable with the least items decides the length of the new iterator. For more info https://www.geeksforgeeks.org/zip-in-JUMP_LINK__&&__python__&&__JUMP_LINK/amp/
25th Nov 2023, 11:20 AM
JaScript
JaScript - avatar
+ 8
In fact, it's very simple, zip(*data) decompresses the tuple data by columns...😎 (0, 1, 2), (3, 4, 5), (6, 7, 8), (9, 10, 11)
25th Nov 2023, 11:27 AM
Solo
Solo - avatar
+ 6
Write in your python code: help("zip") This is very useful to get some information about many topics.
25th Nov 2023, 11:18 AM
Stefanoo
Stefanoo - avatar
+ 5
25th Nov 2023, 2:15 PM
Keith
Keith - avatar
+ 2
Stefanoo thank u
25th Nov 2023, 12:15 PM
Amateur
+ 2
JaScript thank u so much⚘
25th Nov 2023, 12:15 PM
Amateur
+ 2
Solo thank u
25th Nov 2023, 12:16 PM
Amateur
+ 2
Keith thank u
25th Nov 2023, 2:30 PM
Amateur