From the course: Functional Programming with Python

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

Challenge: Converting to list comprehensions

Challenge: Converting to list comprehensions - Python Tutorial

From the course: Functional Programming with Python

Start my 1-month free trial

Challenge: Converting to list comprehensions

(upbeat music) - [Instructor] Now that we've had a lot of practice with Python's functional parts, such as list comprehensions and functions for dealing with iterables, let's do a challenge. The challenge here, to make sure you not only understand how map and filter work but also list comprehensions, is to rewrite the program that we created in a previous video, the program to find the average salary of developers as compared to other professions as we have here. But instead of using the map and filter functions, you're going to do this using list comprehensions. And since there's no good way to recreate the reduce function using list comprehensions, you can either leave this part as reduce or just use Python's built-in sum function. This will probably take you about 10 minutes. Once you've completed it, check out the solution video where I show you how I solved this challenge.

Contents