Isolating free apps, length of free google apps returns 8863 as opposed to 8864 in solutions

Screen Link:

My Code:

paid_google = []
free_google = []
paid_apple = []
free_apple = []

for app in android_english:
    type = app[6]
    if type == 'Free':
        free_google.append(app)
    else:
        paid_google.append(app)

for app in apple_english:
    price = float(app[4])
    if price != 0:
        paid_apple.append(app)
    else:
        free_apple.append(app)

print('Number of paid Google apps:', len(paid_google))
print('Number of free Google apps:', len(free_google))
print('Number of paid Apple apps:', len(paid_apple))
print('Number of free Apple apps:', len(free_apple))

What I expected to happen:
To output free_google apps as 8864

What actually happened:
Returned 8863

Number of paid Google apps: 751
Number of free Google apps: 8863
Number of paid Apple apps: 2961
Number of free Apple apps: 3222

The number of rows in android_english is 9614, and the very first row of that cleaned dataset is not the headers row.

Edit: I re-edited android_english loop to match the solutions:

for app in android_english:
    price = app[7]
    if price == '0':
        free_google.append(app)
    else:
        paid_google.append(app)

I guess the code i used before, one google app’s price & type did not correlate with each other?

Hi TravisBob

Check by the price attribute, and you’ll get the count of 8864.

for app in android_english:
    price = app[7]
    if price == '0.0':
        android_final.append(app)

This might be because of a mismatch between type and price columns.

Please check and let know.
Thanks.

Hi dash.debasmita

With app[7] we will loop over content_rating and not the price attribute, or do I miss there something?

Thanks for your help

Hi c.weisstanner

Welcome to the community.
Here index count starts from 0, hence app[7] will point to price attribute.

android_header, android_apps_data = open_dataset('googleplaystore.csv')
print(android_header[7])

Run the above code, and find out.

Hope its clear now.
Thanks.

Thank you.
I see. I thought I did the counting right, starting with 0, but ended on 6. After some fresh air, I end now on 7;-).
Best

1 Like