Why this doesn't work?

Screen Link:

My Code:

def check_freeapps(dataset_name):
    free_android_apps=[]
    free_apple_apps=[]
    if dataset_name=='android_english':
        for i in dataset_name:
            free_apps=i[7]
            if free_apps==0 :
                free_android_apps.append(i)
    elif dataset_name=='apple_english':
        for i in dataset_name:
            free_apps=i[4] 
            if free_apps==0.0:
                free_apple_apps.append(i)
check_freeapps(android_english)
check_freeapps(apple_english)
print(len(free_android_apps))
print(len(free_apple_apps)) 

ORIGINAL SOLUTION:

android_final = []
ios_final = []

for app in android_english:
    price = app[7]
    if price == '0':
        android_final.append(app)
        
for app in apple_english:
    price = app[4]
    if price == '0.0':
        ios_final.append(app)
        
print(len(android_final))
print(len(ios_final))

What I expected to happen:
8408
2922

What actually happened:
0
0

Paste output/error here

Hi!
I guess the problem is the following:
Your input parameter of the function is dataset_name and literally mean it when compare ==‘android_english’. And then you try to iterate through the name and not the dataset itself.

1 Like