Where did the function inputs go?

Trying to understand the final few steps of the Python 3: String Methods: Review instructions. See link below …

https://www.codecademy.com/courses/learn-python-3/lessons/string-methods/exercises/review-ii

I am not understanding how the final code works without us defining a function that takes in the three inputs (titles, poets, and dates). I see that these were made as three different lists in the step before. But for this final step, I do not see where the inputs are defined (which we’ve been learning to do up until now). So how does the output know to … output the titles, poets, and dates? Please see screenshot below.

Shouldn’t the line circled in green be replaced with something like …

def final_code(titles, poets, dates):

This is me just sticking with the familiar code formula that has been working until now. I’m referring to the lessons right before this Review on format.() I and format.() II. See links below … See how the we’re supposed to always start the code by defining the function and the inputs?

https://www.codecademy.com/courses/learn-python-3/lessons/string-methods/exercises/format-i
https://www.codecademy.com/courses/learn-python-3/lessons/string-methods/exercises/format-ii

We have three lists, all the same length that correspond to one another and could quite easily iterate either of the them, as opposed to the master list and get the same result. The key is the index, which is the same for all three on any given poll.

for i in range(len(titles)):
    print (f"The poem {titles[i]} was published by {poets[i]} in {dates[i]}.")
1 Like

Thank you mtf. Your explanations are the best.

1 Like

This topic was automatically closed 41 days after the last reply. New replies are no longer allowed.