in this quest:
The avg rating of apps which cost more than 9 dollars shall be calculated. I tried it with this way:
opened_file = open(‘AppleStore.csv’)
from csv import reader
read_file = reader(opened_file)
apps_data = list(read_file)
for row in apps_data[1:0]:
if price >9.0:
elif price <=8.0:
elif len(ratings) !=0:
But my avg_rating is 0 instead of a correct result. I don’t see, where I did my mistake… Can someone explain it?
Hi Thomas, welcome to the community!
Here are some things to think about as you look over your code:
- In your loop, you have
apps_data[1:0]. I’m not sure if you meant for the
0 to be there or if it was a typo, but the code in your loop won’t execute properly.
- What are the variables
n_apps_more_9_dollar used for in your code?
After looking over these things, if you’re still stuck, let me know!
On a separate note, when you’re copying and pasting code in the forums, you’ll want to put three backticks before and after your lines of code so that it formats properly. (See this post if it’s unclear.) Thanks!
thanks for the welcome & the tips.
The 0 was exactly the issue. Now it runs smoothly. Thanks a mil!