Aug-20-2020, 02:41 PM
Hello, I have the following code, kindly help what is going on in a simple 1 or 2 lines. set is not hashable, I accept it. dict is not hashable, list is also not hashable, but, why is that we don't get error for list?
Also, why is that I am getting 'set' object is not subscriptable. Please don't mind, it might be stupid questions for you.
Also, why is that I am getting 'set' object is not subscriptable. Please don't mind, it might be stupid questions for you.
s = {{1, 2},{3, 4} } print(s[0][1])
Output:s = {{1, 2},{3, 4} }
TypeError: unhashable type: 'set'
l = [[1, 2], [1, 2]] print(l[0][1])
Output:2
d = { 'cars': {'Innova', 'Honda City', 'BMW'}, 'phones': {'Iphone', 'Samsung', 'Nokia'} } print(d['cars'][0])
Output:print(d['cars'][0])
TypeError: 'set' object is not subscriptable