Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8639821
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T11:07:01+00:00 2026-06-12T11:07:01+00:00

Not sure why this one works when using set and zip: >>> a =

  • 0

Not sure why this one works when using set and zip:

>>> a = ([1])
>>> b = ([2])
>>> set(zip(a,b))
{(1, 2)}

but this one doesn’t ?.

>>> a = ([1],[2])
>>> b = ([3],[4])
>>> set(zip(a,b))
Traceback (most recent call last):
  File "<pyshell#21>", line 1, in <module>
    set(zip(a,b))
TypeError: unhashable type: 'list'

Desired result (1,3) (2,4)

What’s the right way to do this ?

Thanks!

John

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T11:07:02+00:00Added an answer on June 12, 2026 at 11:07 am

    It makes more sense if we look at the zip output:

    >>> a = ([1]) # equivalent to [1], not a tuple
    >>> b = ([2]) # equivalent to [2], not a tuple
    >>> list(zip(a,b))
    [(1, 2)]
    
    >>> a = ([1],[2])
    >>> b = ([3],[4])
    >>> list(zip(a,b))
    [([1], [3]), ([2], [4])]
    

    In the first case, the list contains a tuple of ints; in the second case, it contains tuples of lists and lists are not hashable.

    In the first case, if you wanted a singleton tuple containing a list, you should use a = ([1],) and b = ([2],). If you define a and b that way, then set(zip(a, b)) will fail like it does in the second case.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Not sure if this is possible in one Makefile alone, but I was hoping
I got couple of crash reports like this one and I'm not sure what
I'm not sure if this is possible in one mysql query so I might
Sorry, I'm not really sure of the right way to ask this one so
This is a very odd one and I'm not sure how to proceed. Basically,
Not sure this is a known issue. I’m using VS2012 RC (Ultimate), and Win8
Not sure this is possible, but looking to write a script that would return
I'm not sure this is even possible but I know if it is, the
Not sure if this would be better on Programmers or another Exchange but here
I'm not sure the specific implementation is important here but for completeness I'm using

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.