Error: List assignment index out of range

Screen Link:

My Code:

reviews_max = {}
apps_data_google = apps_data_google[1:]
for apps in apps_data_google:
    name = apps[0]
    del apps_data_google[10472]
    n_reviews = float(apps[3])
    if (name in reviews_max) and (reviews_max[name] < n_reviews):
        reviews_max[name] = n_reviews
    elif name not in reviews_max:
        reviews_max[name] = n_reviews
unique_apps(apps_data_google)        
print('expected length:', len(reviews_max))

What I expected to happen:
successfully converted to the float and print the expected length of 9659

What actually happened:


IndexError                                Traceback (most recent call last)
<ipython-input-73-fc085cc2e0ba> in <module>
      3 for apps in apps_data_google:
      4     name = apps[0]
----> 5     del apps_data_google[10472]
      6     n_reviews = float(apps[3])
      7     if (name in reviews_max) and (reviews_max[name] < n_reviews):

IndexError: list assignment index out of range

Thanks for helping!!!

In every iteration you are deleting item at index 10472.

The IndexError results since the assignment is out of range (can’t be found)

you should remove this in the loop and place it before the loop

Code
reviews_max = {}
apps_data_google = apps_data_google[1:]
del apps_data_google[10472]
for apps in apps_data_google:
    name = apps[0]
    n_reviews = float(apps[3])
    if (name in reviews_max) and (reviews_max[name] < n_reviews):
        reviews_max[name] = n_reviews
    elif name not in reviews_max:
        reviews_max[name] = n_reviews
unique_apps(apps_data_google)        
print('expected length:', len(reviews_max))