I'm wondering why zip()
was designed to return tuples and not lists for instance. Is it something that has to do with performance or mutability? Or is it something else?
In the fact is that the zip function is designed to :
Return a list of tuples, where each tuple contains the i-th element from each of the argument sequences. (Source: the docstring of zip function)
From this with given arguments you only get one possible result which can't be affected by something else than input that you give. So if the result was list you can modify it and the result will no more be the one expected. The tuples are the solution because they are immutable and you can't affect the result.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With