The code is correct but im getting Error.
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_sum + rating
avg_rating = rating_sum / len(app_data_set)
Hi @isrealsho, yes, your code seems correct as shown below.
Could you please indicate the error you are getting in running the code?
@isrealsho, thanks for posting the error.
The error is due to the fact that you have not indented codes that need to be executed within the for loop statement. To address this, You have to indent the 2 lines of code immediately after the for loop statement. When your mouse pointer is at the end of the for row in app_data_set:, and you press Enter on the keyboard, the next line is automatically indented. Type rating = row[-1] after the indentation, when you hit Enter, the next line will still be indented - type rating_sum = rating_sum/len(app_data_set) after the indentation. The codes after this should not be indented.
You can also manually indent by pressing Space on the keyboard 4 times (which is the convention in Python) before typing a line of code that need to be indented.
Please refer to the code below for solution which shows how the 2 lines of code after the for loop statement should be indented or see my earlier post.
Let me know if this helps. Best!
I did these and its worked…
@isrealsho, Good to know you have addressed the problem. If my response helped could you please mark as solution. You may refer to the following post if needed:How do I mark a post as solved?