List and For Loops - Step9 - Validation failure

https://app.dataquest.io/m/312/lists-and-for-loops/9/for-loops

My Code:

row_1 = ['Facebook', 0.0, 'USD', 2974676, 3.5]
row_2 = ['Instagram', 0.0, 'USD', 2161558, 4.5]
row_3 = ['Clash of Clans', 0.0, 'USD', 2130805, 4.5]
row_4 = ['Temple Run', 0.0, 'USD', 1724546, 4.5]
row_5 = ['Pandora - Music & Radio', 0.0, 'USD', 1126879, 4.0]

app_data_set = [row_1, row_2, row_3, row_4, row_5]

rating_sum = 0

for value in app_data_set:
    rating = value[-1]
    rating_sum += rating

print(rating_sum)

avg_rating = rating_sum / len(app_data_set)

print(avg_rating)

The code above works fine and give the expected values of 21.0 for sum and 4.2 for avg_rating.

What happen is when I try to submit my solution it give me the below error, it happened even when I copied the answer exactly

avg_rating isn’t defined in your code, but we expected it to be float type
rating_sum isn’t defined in your code, but we expected it to be float type

 avg_rating ()
- actual + expected

- [undefined]
+ 4.2
 rating_sum ()
- actual + expected

- [undefined]
+ 21
1 Like

Hello!

Your code looks fine. It even works on the mission’s screen. Try to delete everything in the script and paste this code. If it does not work, I think it may be a case of bug report.

2 Likes

Hi,
I tried deleting the script and also restoring the code and got the same issue, however the issue went away after I cleared Chrome cache.
Appreciate the help.

Regards

AliAS

1 Like

Hello, I’m also having the same problem with case 9/13
Is there any update solution yet to this problem?

As @aliasalman86 the issue went away after he cleared Chrome cache. You can try that.

If it does not help, it could be error in the code. In this case, you’ll need to post the code so we can help.

Strange, after I restarted my PC, the problem is gone.
Nonetheless, thanks for your respond.

Hi. It looks like Dataquest has a bug on this screen. Dataquest need to fix this soon to avoid frustration among the learners.

This screen seems to be working just fine. If you are experiencing any issue, please post the code you are running and the error you get.

Same problem here.

I tried clearing Firefox cache but still getting the same problem again. Also tried to clear cache + close browser and reopening it, but it doesn’t seem to work either.

Hello @borjadn93, welcome to the community!

Can you post your code?

Yes, it is almost the same code as the posted one:

row_1 = ['Facebook', 0.0, 'USD', 2974676, 3.5]
row_2 = ['Instagram', 0.0, 'USD', 2161558, 4.5]
row_3 = ['Clash of Clans', 0.0, 'USD', 2130805, 4.5]
row_4 = ['Temple Run', 0.0, 'USD', 1724546, 4.5]
row_5 = ['Pandora - Music & Radio', 0.0, 'USD', 1126879, 4.0]

app_data_set = [row_1, row_2, row_3, row_4, row_5]

rating_sum = 0

for row in app_data_set:
    rating = row[-1]
    rating_sum += rating
    
avg_rating = rating_sum / len(app_data_set)

print('Sum: ', str(rating_sum), ', Average: ', str(avg_rating))

It is strange because today it seems to work fine…Yesterday I tried opening the site both with Firefox and Chrome and did the cache thing and didn’t work.

1 Like

Your code looks fine, yes. If it happens again, don’t hesitate to ask.

Hi,am also having a similar problem with case 9/13. I have been stuck for the past 3 weeks now. I have followed all the instructions given but its still the same. Please I need a solution to the problem.

Hi @bauzy2357,

Can you please share with us your code? That way it will be easier to see the problem.

Hello @bauzy2357.

If your problem is happening in a different mission or step, I suggest you create a new topic explaining it. Make sure to share your code and to post a link to the screen.

I have the same issue, my code is as follows:

row_1 = ['Facebook', 0.0, 'USD', 2974676, 3.5]
row_2 = ['Instagram', 0.0, 'USD', 2161558, 4.5]
row_3 = ['Clash of Clans', 0.0, 'USD', 2130805, 4.5]
row_4 = ['Temple Run', 0.0, 'USD', 1724546, 4.5]
row_5 = ['Pandora - Music & Radio', 0.0, 'USD', 1126879, 4.0]

app_data_set = [row_1, row_2, row_3, row_4, row_5]

rating_sum = 0

for each_row in app_data_set:
    rating = each_row[-1]
    rating_sum = rating_sum + rating 
    print(rating_sum)
    
avg_rating = rating_sum / 5

print(avg_rating)
1 Like

Hello @NewBev, welcome to the community.

Your code is working just fine on my end. Try to clear your browser cache as this worked for the other users.


Anyway, it seems we’re having the same problem over and over with different users on this screen. Do you think it is worth looking into this, @Sahil?

1 Like

Hi @otavios.s

Yes, this seems to be a recurring issue. I have reported this issue to the engineering team and created bug topic for it here:

Best,
Sahil

1 Like