Profitable app project code not matching the solution

Screen Link:

My Code:

android_free = []
ios_free = []

for value in android_english:
    price = value[7]
    if price == '0':
        android_free.append(value)
        
for value in ios_english:
    price = value[4]
    if price == '0.0':
        ios_free.append(value)
        
print(len(android_free))
print(len(ios_free))

What I expected to happen:
8864
3220

What actually happened:
8864
0

Replace this line with the output/error

I can’t seem to understand why the output of this code print(len(ios_free)) is giving the value 0. Please help. Thanks

Hello @MirzaWaleed, welcome to the community!

Your code looks correct.
But first, try to check and be sure that the ios_english list of lists is not empty and that it contains the correct dataset.

1 Like

@MirzaWaleed: I don’t think I have access to that particular project. Do check the index of value which you are storing in price. Also, if price is a float, check that it is a float, if it is an integer, check that its an int.

for value in android_english:
    price = value[7] # check this
    if price == '0': # if int, check if price == 0. if float check if price == 0.0
        android_free.append(value)
        
for value in ios_english:
    price = value[4] # check this
    if price == '0.0': # if int, check if price == 0. if float check if price == 0.0
        ios_free.append(value)
        

Hope this helps!

2 Likes

Thanks for the help guys.

1 Like

@MirzaWaleed: No worries! :smile:

You’re welcome. Happy Studying!