Python’s in operator tests whether a value occurs in a sequence or collection. For example, if word[0] in 'aeiou' is True, the word begins with a vowel. This replaces repetitive loops and chained or conditions with a readable, Pythonic expression. section 3.3
if word[0] in 'aeiou':
Use membership testing directly when checking whether a character occurs in a string. section 3.3
Keep these behaviors in mind:
- Apply in to strings, lists, tuples, and many other collections; searching takes time proportional to the sequence length. section 3.3
- Search a dictionary with in to test keys, not values, then retrieve the associated value separately. section 3.3 section 5.5
- Normalize user input when appropriate: capitalization affects dictionary-key matching, and casefold supports broader character handling. section 5.5
Restaurant menu
Check whether an order is a menu key before adding its price to a running total; reject unknown dishes, and stop when the stripped input is empty. section 5.4 section 5.5







