Python Quest

Track 3 · Lesson 8 of 11

Membership tests and range checks

Test whether a value is one of several options or contains some text with in and not in, and check ranges with comparisons and range().

About 35 minBeginner4 exercises

You will be able to

  • Check whether text contains a substring with in and not in
  • Check whether a value is one of a fixed set of options written as a tuple
  • Check whether a whole number lies in range(start, stop), remembering stop is excluded
  • Avoid the trap of testing membership in a string when you meant a set of words

Included with a Formula Quest membership

It has 4 graded exercises with feedback, hints and solutions. Python Quest is included in Formula Quest memberships that cover Python; membership and billing are managed on Formula Quest.

View Formula Quest memberships

Tracks 1 and 2, the first lesson of every track, the playground and the dataset library are free.