TypeError: 'zip' object is not callable in Python 3.x

前端 未结 1 882
谎友^
谎友^ 2021-01-12 11:42

I\'m trying to zip 2 simple lists in Python 3.5, and can\'t figure out how to access the contents. I\'ve read now that zip() is a generator, and I have to call

相关标签:
1条回答
  • 2021-01-12 12:38

    that happens when you redefine list as zip() (which is probably what you did but didn't show us):

    >>> list = zip()
    

    now list is a zip object (not the zip class)

    >>> list(z)
    

    now you're attempting to call a zip object

    Traceback (most recent call last):
      File "<string>", line 301, in runcode
      File "<interactive input>", line 1, in <module>
    TypeError: 'zip' object is not callable
    >>> 
    

    just

    del list
    

    (or start from a fresh interpreter)

    and everything's back to normal

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