Opening the book…
The expression event.key in (K_LEFT, K_a) is just a Python trick to make the code simpler. It is a way of saying "evaluate to True if event.key is equal to one of K_LEFT or K_a". The following two expressions will evaluate the exact same way:
event.key in (K_LEFT, K_a) event.key == K_LEFT or event.key == K_a
You can really save on some space by using this trick when you have to check if a value is equal to one of multiple values. The following two expressions will evaluate the exact same way:
spam == 'dog' or spam == 'cat' or spam == 'mouse' or spam == 'horse' or spam == 42 or spam == 'dingo'
spam in ('dog', 'cat', 'mouse', 'horse', 42, 'dingo')
This page titled 5.10: “Equal To One Of” Trick with the in Operator was last modified on Sat, 02 Nov 2019 23:07:09 GMT and is shared under a CC BY-NC-SA 3.0 license and was authored, remixed, and/or curated by Al Sweigart via source content that was edited to the style and standards of the LibreTexts platform.
The book could not be loaded just now.