Course Content
Python Functions Tutorial
Python Functions Tutorial
1. What is a Function in Python?
2. Positional and Optional Arguments
4. Function Return Value Specification
5. Recursion and Lambda Functions
Challenge: Search Engine
Task
Swipe to start coding
You need to implement a recursive function that searches for a file in a dictionary by its name. The dictionary contains file information, where each file has a unique id
, name
, and path
. The function should return the details of the file when it finds a match for the specified file name.
- Complete the code by filling in the missing parts (
___
) in the given function. - If the dictionary is empty, the function should return
None
. - If a file with the target name is found, the function should return the details of that file.
- The function should recursively check the remaining files after each file is checked, until the target file is found or all files are checked.
Solution
Everything was clear?
Thanks for your feedback!
Section 5. Chapter 2
Challenge: Search Engine
Task
Swipe to start coding
You need to implement a recursive function that searches for a file in a dictionary by its name. The dictionary contains file information, where each file has a unique id
, name
, and path
. The function should return the details of the file when it finds a match for the specified file name.
- Complete the code by filling in the missing parts (
___
) in the given function. - If the dictionary is empty, the function should return
None
. - If a file with the target name is found, the function should return the details of that file.
- The function should recursively check the remaining files after each file is checked, until the target file is found or all files are checked.
Solution
Everything was clear?
Thanks for your feedback!
Section 5. Chapter 2