Skip to main content

Section 7.7 The in operator

The word in is a boolean operator that takes two strings and returns True if the first appears as a substring in the second:

Checkpoint 7.7.1.

    11-9-2: True or False? The word in is a boolean operator.
  • True
  • Correct! in is a boolean operator that takes two strings and returns True if the first is part of the second.
  • False
  • Incorrect! in is a boolean operator. Try again.

Checkpoint 7.7.2.

    11-9-3: True or False? The following code returns True.
    'i' in 'lime'
    
  • True
  • Correct! This returns True because there is a string 'i' within the string 'lime'.
  • False
  • Incorrect! There is an 'i' in lime, so this will return True. Try again.

Checkpoint 7.7.3.

    11-9-4: True or false? The following code returns True.
    'hat' in 'chatter'
    
  • True
  • Correct! This returns True because there is a string 'hat' within the string 'chatter'.
  • False
  • Incorrect! The string 'chatter' contains the substring 'hat'. Try again.