Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update transposition snippet (python) #634

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

pshabunia
Copy link

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 is a nice trick but it doesn't output a matrix. The output of zip is an iterator of tuples. You can't use it for accessing elements of matrix by index.

`transposed_matrix[0][0]` will raise an error
`TypeError: 'zip' object is not subscriptable`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant