Python Forum
Why the IDE cannot show the result of zip function?
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Why the IDE cannot show the result of zip function?
#1
Here is my codes,I am trying to zip two lists
a = [1,2,3]
b = [4,5,6]

print(zip(a,b))
It just printed the location

Error:
<zip object at 0x10c6b2488>
May i ask why is it so?
Reply
#2
zip function returns a zip object, which is an iterator. Iterators are a somewhat broader subject, but you can find an overview to catch up, such as this one.
If you want to display the zip object as a list, convert it to a list with:

print(list(zip(a,b)))
Reply
#3
(May-18-2018, 05:10 AM)Tony Wrote: Here is my codes,I am trying to zip two lists
 a = [1,2,3] b = [4,5,6] print(zip(a,b)) 
It just printed the location
Error:
<zip object at 0x10c6b2488>
May i ask why is it so?
(May-18-2018, 05:20 AM)j.crater Wrote: zip function returns a zip object, which is an iterator. Iterators are a somewhat broader subject, but you can find an overview to catch up, such as this one. If you want to display the zip object as a list, convert it to a list with:
print(list(zip(a,b)))
Thank you so much, that helps a lot
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  PIL Image im.show() no show! Pedroski55 2 967 Sep-12-2022, 10:19 PM
Last Post: Pedroski55
  PIL Image im.show() no show! Pedroski55 6 4,911 Feb-08-2022, 06:32 AM
Last Post: Pedroski55
  unable to use result of solver in another function ross1993hall 0 1,414 Aug-10-2020, 10:29 AM
Last Post: ross1993hall
  How to use function result in another function Ayckinn 4 2,832 Jun-16-2020, 04:50 PM
Last Post: Ayckinn
  Pandas's regular expression function result is so strange cools0607 6 3,182 Jun-15-2020, 07:34 AM
Last Post: cools0607
  Confusion with datetime 'dst' function result jsmith1703 4 3,341 Nov-16-2019, 02:55 AM
Last Post: DeaD_EyE

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020