zip function giving incorrect output

前端 未结 1 1665
挽巷
挽巷 2020-12-10 15:25

I am writing some cryptographic algorithm using Python, but I have never worked with Python before.

First of all, look at this code then I\'d explain the issue,

相关标签:
1条回答
  • 2020-12-10 16:22

    In Python 3 zip returns an iterator, use list to see its content:

    >>> list(zip((1,2,3),(10,20,30),(100,200,300)))
    [(1, 10, 100), (2, 20, 200), (3, 30, 300)]
    

    c = [ i ^ j for i, j in zip( x, y ) ] is a list comprehension, in this you're iterating over the items returned from zip and doing some operation on them to create a new list.

    0 讨论(0)
提交回复
热议问题