1. Learn
  2. /
  3. Courses
  4. /
  5. Python Data Science Toolbox (Part 1)

Exercise

Nested Functions I

You've learned in the last video about nesting functions within functions. One reason why you'd like to do this is to avoid writing out the same computations within functions repeatedly. There's nothing new about defining nested functions: you simply define it as you would a regular function with def and embed it inside another function!

In this exercise, inside a function three_shouts(), you will define a nested function inner() that concatenates a string object with !!!. three_shouts() then returns a tuple of three elements, each a string concatenated with !!! using inner(). Go for it!

Instructions

100 XP
  • Complete the function header of the nested function with the function name inner() and a single parameter word.
  • Complete the return value: each element of the tuple should be a call to inner(), passing in the parameters from three_shouts() as arguments to each call.