Python Quest

Track 7 · Lesson 5 of 11

Validating text

Check that input has the right shape using isdigit, isalpha and friends (and their Unicode caveats), then combine small checks into validators.

About 45 minIntermediate4 exercises

You will be able to

  • Use isdigit(), isdecimal(), isalpha(), isalnum(), isspace(), isupper() and islower() and predict their results on edge cases
  • Explain why isdigit() accepts characters such as ² and Arabic-Indic digits, and restrict a check to ASCII when needed
  • Write validator functions that combine length, position and character checks with early returns
  • Validate realistic formats: PIN codes, product codes, email addresses and phone numbers

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.