+ 2
Why is it printing a tuple instead of a list?
8 odpowiedzi
+ 2
That's just what zip does: Returning a tuple of the n-th elements of your iterables.
+ 1
Use [ ] brackets for list and ( ) For tuples
+ 1
Can you explain the function zip() and list(), why list() should be used twice?
+ 1
There is no need to use list twice in this code. It can be done like this:
a = range(10)
print(list(zip(a, a))[9])
# or like this: ( when 2 different ranges should be used like print(list(zip(range(0,10), range(3,13)))[9])
print(list(zip(range(10), range(10)))[9])
0
Thanks