0

I am currently using Python 3.7.3 and am relatively new. My understanding was that the zip() function returns a list of tuples, however in practice I have found it returns a 'zip' object. Is there a way that I can get this function to return a list of tuples or a similar function that can accomplish my purpose? Thanks so much!

I don't know if that was automatic or a mod did that, but thank you!

  • "My understanding was that the zip() function returns a list of tuples" your undersanding is incorrect. `zip` returns a `zip` objet `zip` is a class. This object is an iterator, so just create a list out of it – juanpa.arrivillaga Nov 19 '20 at 19:01
  • `zip` *used* to return a list of tuples, in Python 2. – chepner Nov 19 '20 at 19:01
  • You only need the `list` function to turn a zip object into the corresponding list – khelwood Nov 19 '20 at 19:03

1 Answers1

3

All you need to do is convert it to a list.

list(zip(....))
wakey
  • 2,283
  • 4
  • 31
  • 58
MaxTechniche
  • 141
  • 5