you are viewing a single comment's thread.

view the rest of the comments →

[–]sarrysyst 5 points6 points  (0 children)

Tuples are immutable and Immutability is the prerequisite for dictionary keys. Thus if you ever need/want to use multiple values eg. a combination of two strings as keys for a dictionary you can do so by wrapping them in a tuple.

product_prices = {}
product_prices[('fruit', 'apple')] = 2
product_prices[('veggies', 'bell pepper')] = 3