We're sorry but this app doesn't work properly without JavaScript enabled. Please enable it to continue.

This lesson's interactive features are locked, please to keep using them

More Transformations

Here's some example code for you to reference as you work through the assignment:

from collections.abc import Callable


def multiply(x: int, y: int) -> int:
    return x * y


def add(x: int, y: int) -> int:
    return x + y


def self_math(math_func: Callable[[int, int], int]) -> Callable[[int], int]:
    def inner_func(x: int) -> int:
        return math_func(x, x)

    return inner_func


square_func: Callable[[int], int] = self_math(multiply)
double_func: Callable[[int], int] = self_math(add)

print(square_func(5))
# prints 25

print(double_func(5))
# prints 10

Assignment

Complete the doc_format_checker_and_converter function. It takes a conversion_function and a list of valid_formats as parameters. It should return a new function that takes two parameters of its own:

  • filename: The name of the file to be converted
  • content: The content (body text) of the file to be converted
  1. invalid file format
    

Tips

  • You can use the .split() method on the filename to get the file extension. Then use the in keyword to check if a value is in a list.
  • capitalize_content and reverse_content are "conversion functions" that will be passed into our doc_format_checker_and_converter function by the tests.