Trouble Undersanding For Loop example in Guided Project 1: Prison Break (10: Attempts per year)

Screen Link: Learn data science with Python and R projects

At this point in the Guided Project, we are shown how to find the amount of helicopter prison break attempts per year. We are shown how to create a for loop within a for loop and the mechanics are throwing me off.

Instruction 1 - for each row in data

for ya in attempts_per_year: # Instruction 2 - nothing to do here
    # Instruction 3 - assign the year value in ya to y
    if row[0] == y:
        ya[1] += 1

Instruction 4 - print the results

What I expected to happen:
I am just confused as to what is going on in general. From what I understand we are seeing when the year attempted in the Data loop matches the year attempted in the attempts per year loop and then incrementing the attempts whenever they match up.

There is a lot going on and is a bit overwhelming at the moment, but what do I put in #instruction #3 and how does this fit into our overall goal of incrementing years_attempted?

Thank you in advance.

Hey @rfarivar74. Instruction 3 is y=ya. So, we need to pick years ya from attempts_per_year ,assign it to a temporary variable y in the for loop, so that we can check if row[0] == y, and then increment the attempts in attempts_per_year using ya[1] += 1. I hope this makes it a bit clear.
And we all get overwhelmed sometimes, especially when coding. Take a break at times, so that you can enjoy the process more.

Hi @rfarivar74

Hope the comment above helps you.
When in doubt, try printing the variables inside the for loop and see what they are showing. This will help you to understand what is row[0] what is y or ya and so on.