Heads up! To view this whole video, sign in with your Courses account or enroll in your free 7-day trial. Sign In Enroll
Start a free Courses trial
to watch this video
Standalone functions are great but when we're writing small functions, we often need to do more work than we can achieve in a single function. Luckily, we can chain functions so long as we write them correctly.
Since filter()
, map()
, sorted()
, and friends all return iterables, we can chain them together. Chained functions resolve, or happen, from the inside out, so the innermost function runs first.
This is another reason why functions usually return
a value at the end. It makes it easier to use them all together.
any(iterable)
returns True
if any of the items in the iterable are truthy. Similar is the function all()
. all(iterable)
returns True
if all of the items in the iterable are truthy.
Watch our comprehensions workshop if you want more information.
Related Discussions
Have questions about this video? Start a discussion with the community and Treehouse staff.
Sign upRelated Discussions
Have questions about this video? Start a discussion with the community and Treehouse staff.
Sign up
You need to sign up for Treehouse in order to download course files.
Sign upYou need to sign up for Treehouse in order to set up Workspace
Sign up