recursive function
You were to call the function that you’ll create print_lol(). It takes one argument: a list to display on screen. You were to grab your pencil and complete the code to provide the required functionality: def print_lol(the_list): for each_item in the_list: Process the provid ed p. loo r” “fo a h wit list
isinstance(each_item, list):
if
else:
print_lol(each_item) print(each_item)
If the item being processed is itself a list, invoke the function. ’T If the item being processed ISN . een scr a list, display the item on
Let’s use IDLE one final time to test your new function. Will it work as well as your earlier code? >>> def print_lol(the_list):
for each_item in the_list:
if isinstance(each_item, list):
Define the function.
print_lol(each_item) else:
print(each_item)
>>> print_lol(movies)
Invoke the function.
The Holy Grail 1975 Terry Jones & Terry Gilliam 91 Graham Chapman Michael Palin John Cleese Terry Gilliam Eric Idle Terry Jones
30 Chapter 1
It works, too! The recusrive ction produces EXACTLY the samfun e res ults as the earlier code.