Python Forum
TypeError: unhashable type: 'set'
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
TypeError: unhashable type: 'set'
#2
I think you are trying to look up the value in dict2 for each of the numbers in dict1 (like 1, 2, 3, 4, etc.)

But the values in dict1 aren't numbers, they're sets of numbers. So your program is trying to find the value of the set itself, and that's not possible.

If you want to unpack the sets, maybe import itertools and then you can
print(max(list(itertools.chain.from_iterable(dict1.values())),key=dict2.get))
Reply


Messages In This Thread
TypeError: unhashable type: 'set' - by Stager - Jun-08-2020, 01:39 PM
RE: TypeError: unhashable type: 'set' - by bowlofred - Jun-08-2020, 04:11 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Unhashable error - Histogram code lsbpython 1 1,012 Aug-07-2022, 04:02 PM
Last Post: Yoriz
  TypeError: unsupported operand type(s) for +: 'dict' and 'int' nick12341234 1 9,373 Jul-15-2022, 04:04 AM
Last Post: ndc85430
  TypeError: unsupported opperand type(s) for %: 'int' and 'list' cool_person 7 2,248 May-07-2022, 08:40 AM
Last Post: ibreeden
  You have any idea, how fix TypeError: unhashable type: 'list' lsepolis123 2 3,044 Jun-02-2021, 07:55 AM
Last Post: supuflounder
  TypeError: __str__ returned non-string (type tuple) Anldra12 1 7,437 Apr-13-2021, 07:50 AM
Last Post: Anldra12
  TypeError: 'type' object is not subscriptable Stef 1 4,562 Aug-28-2020, 03:01 PM
Last Post: Gribouillis
  TypeError: __repr__ returned non-string (type dict) shockwave 0 3,209 May-17-2020, 05:56 PM
Last Post: shockwave
  calculate_bai -- TypeError: unsupported operand type(s) for *: 'float' and 'NoneType' pantherd 1 3,279 Apr-21-2020, 12:31 PM
Last Post: anbu23
  TypeError: can't multiply sequence by non-int of type 'float' DimosG 3 3,398 Apr-04-2020, 05:16 AM
Last Post: michael1789
  TypeError: size; expecting a recognized type filling string dict a11_m11 0 2,550 Feb-10-2020, 08:26 AM
Last Post: a11_m11

Forum Jump:

User Panel Messages

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