Atma
Atma

Reputation: 29767

python TypeError unhashable type list

I have the following dictionary:

equipment_element = {'equipment_name', [0,0,0,0,0,0,0]}

I can't figure out what is wrong with this list?

I'm trying to work backwards from this post Python: TypeError: unhashable type: 'list'

but my key is not a list, my value is.

What am I doing wrong?

Upvotes: 0

Views: 498

Answers (3)

Ishan Srivastava
Ishan Srivastava

Reputation: 1189

maybe you were looking for this syntax

equipment_element = {'equipment_name': [0,0,0,0,0,0,0]}

or

equipment_element = dict('equipment_name' = [0,0,0,0,0,0,0])

or

equipment_element = dict([('equipment_name', [0,0,0,0,0,0,0])])

This syntax is for creating a set:

equipment_element = {'equipment_name', [0,0,0,0,0,0,0]}

Upvotes: 0

Sunitha
Sunitha

Reputation: 12015

You are trying to create set, not a dictionary

Modify it as follows. Replace the , in between to :

equipment_element = {'equipment_name': [0,0,0,0,0,0,0]}

Upvotes: 2

Tom Wojcik
Tom Wojcik

Reputation: 6179

It's not a dictionary, it's a set.

Upvotes: 3

Related Questions