LernerPython

Comprehending comprehensions

Comprehensions have a reputation for being difficult to learn, understand, and use. And besides, who needs them, when we have “for” loops? This course will teach you why comprehensions exist, how to write them, and why you want to be using them in your Python code.

What you should know

Course Content

Course length

2 hours

Number of lessons

21

Training materials

1 Jupyter notebook + files for exercises

Coding exercises

15

LEARN MORE

Comprehensions — list, dict, and set — are a powerful Python feature that make your code shorter, more efficient, and more expressive. However, a large number of Python developers think of comprehensions as nothing more than “for” loops with a hard-to-understand syntax, and avoid using them. That’s a shame, because comprehensions aren’t that hard, and are quite useful for solving a wide variety of problems.

This course will explores comprehensions, starting with the basic syntax and use cases, working up to nested comprehensions that allow us to solve more complex problems. The course includes a large number of hands-on exercises, as well as an even larger number of live-coding demos.

By the time the course is over, you will no longer wonder when or how to use comprehensions. Instead, you’ll know how, when, and why to use comprehensions, making you a more fluent Python developer.

  • How list, set, and dict comprehensions work
  • When to use comprehensions, and when to use regular “for” loops
  • How to solve problems elegantly with comprehensions
  • How nested comprehensions work, and when you should use them

This course, like all others at LernerPython, is taught by Reuven Lerner.