zipping the matrix is a nice trick but it doesn't always produce what you need (a matrix) in a time-sensitive interview environment. The output of zip is an iterator of tuples which doesn't allow accessing elements by index. Converting the iterator of tuples to matrix takes the same amount of code as transposing the matrix itself
transposed_matrix[0][0] will raise an error
TypeError: 'zip' object is not subscriptable
zip
ping the matrix is a nice trick but it doesn't always produce what you need (a matrix) in a time-sensitive interview environment. The output ofzip
is an iterator of tuples which doesn't allow accessing elements by index. Converting the iterator of tuples to matrix takes the same amount of code as transposing the matrix itselftransposed_matrix[0][0]
will raise an errorTypeError: 'zip' object is not subscriptable