Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

immutable collection: tuple as dictionary key

points = {}
p1 = (2, 3)

points[p1] = 'Joe'
points[(17, 5)] = 'Jane'

print(points)
for k in points.keys():
   print(k)
   print(k.__class__.__name__)
   print(points[k])
{(2, 3): 'Joe', (17, 5): 'Jane'}
(2, 3)
tuple
Joe
(17, 5)
tuple
Jane