My first guided project_succeed, but not enough

Hi! I’m just starting learning Python and that’s my first guided project.
While I was coding it I found some difficults in this part:

for row in data:
for ya in attempts_per_years:
y = ya[0]
if row[0] == y:
ya[1] += 1

I’m sorry because I think that it is a very stupid doubt, but…where ya comes from, if I named a variable as y?

This is not the only passage where I found trouble, but I hope that on going I will understand also the rest of this.

this is my notebook

Hi Beatrice,

Inside your for boucle you are iterating through attempts_per_years using this variable named “ya” which looks like to be a list.
In reality your variable “y” is superfluous here since you can just write:

if row[0] == ya[0]:
    ya[1] += 1

Note that you didn’t give the link of the course so it’s not possible to fix errors if there are. I don’t understand what you are doing in fact, but it looks strange being incrementing “ya” here and then printing “attempts_per_years” which didn’t change during the loop. So I guess:

for idx, ya in enumerate(attempts_per_years):
   if row[0] == ya[0]:
       attempts_per_years[idx][1] += 1

is the right code ?

Also the link of your notebook is broke.

1 Like

Hi WilfriedF and thank you so much for your answer.
I see that the link doesn’t work. I saved it as code in the windows notepad if you want.
PrimoProgettoPython.txt (1.7 KB)

1 Like

Hello @beatrice.pietra, to make sure that we can correctly visualize your project, please upload an ipynb file to this topic.