Track 9 · Lesson 8 of 11
EAFP versus LBYL
Compare 'easier to ask forgiveness than permission' with 'look before you leap', and choose between try, an if check and dict.get for each situation.
You will be able to
- Describe the EAFP and LBYL styles and recognise each in code
- Choose between dict.get, an in check and try/except KeyError for a lookup
- Explain why checks like isdigit() are a poor substitute for trying a conversion
- Use EAFP to reach into nested data without a chain of checks
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.