Free Apps Isolation

Please I don’t seem to understand this code below.
free_googleApps = [ ]
free_appleApps =[ ]

for app in google_englishApps:
price = app[7]
if price == 0:
free_googleApps.append(app)

for this_app in apple_englishApps:
price = app[4]
if price == '0.0:
free_appleApps.append(this_app)

Length of google apps =8864
Lengths of Apple apps = 0

When I replace the prices to “0” and try printing out the length, I get length of apple as zero. But when I replace it to “0.0”, I get the corrent length, please, why is it like this…

Thanks.

The best way to understand the difference is go to back up to the cell where we first explored our data.
Here is one of the rows of the Google dataset:

['Photo Editor & Candy Camera & Grid & ScrapBook', 'ART_AND_DESIGN', '4.1', '159', '19M', '10,000+', 'Free', '0', 'Everyone', 'Art & Design', 'January 7, 2018', '1.0.0', '4.0.3 and up']

And here is one of the rows of the Apple dataset:

['284882215', 'Facebook', '389879808', 'USD', '0.0', '2974676', '212', '3.5', '3.5', '95.0', '4+', 'Social Networking', '37', '1', '29', '1']

For both the Google and Apple datasets, the price is stored as a string. This means that, technically, '0' and '0.0' are not the same thing, just like 'a' and 'A' are not the same. If the code is looking for the value to be equivalent to '0' in the Apple dataset, then none of the rows will match because they’re using '0.0'.

I hope that helps clear things up!

1 Like