I'd like to create a dict where multiple different keys will map to the same value. I have seen this question, but it's still a little unsatisfying. I would like this behavior:
test = {
'yes' or 'maybe': 200,
'no': 100
}
test['yes']
--> 200
test['maybe']
--> 200
test['no']
--> 100
Instead, I get this behavior. It's interesting that the dict can init at all. What is going on here?
test = {
'yes' or 'maybe': 200,
'no': 100
}
test['yes']
--> 200
test['maybe']
--> KeyError
test['no']
--> 100
# If I change to and:
test = {
'yes' and 'maybe': 200,
'no': 100
}
test['yes']
--> KeyError
test['maybe']
--> 200
test['no']
--> 100