Oh OK!
In this case you actually should append to app
. I’ll explain.
Your apps_data
variable is a list full of other lists. A list of lists. It is your dataset.
Try to see this list of lists as a table where each list inside is a row of the table.
The first row (the first list inside the list of lists) is the header. That’s why when you use the for
you use apps_data[1:]
, because apps_data[0]
is the header, not the data.
In this particular case, what you are trying to do is to add another column to your whole dataset. Therefore you need to append one extra value in each row (each list). But what value?
In this case you are trying to specify if the app is free or not. That’s why for app in apps_data[1:]:
you you check if the price of the app is 0. If so, you’ll then append the label free
to its column. If not you’ll append non-free
.
This is the original row of your data set (as said, a list):
'284882215', 'Facebook', '389879808', 'USD', '0.0', '2974676', '212', '3.5', '3.5', '95.0', '4+', 'Social Networking', '37', '1', '29', '1']
As you can see, the price is zero. So you’ll append the label free
to it, and then your row will be:
'284882215', 'Facebook', '389879808', 'USD', '0.0', '2974676', '212', '3.5', '3.5', '95.0', '4+', 'Social Networking', '37', '1', '29', '1', 'free']
Does it make sense now?
Notice that after the loop, you add the name of the new column you just created to the header:
apps_data[0].append('free_or_not')
Try to see it as a table:
['id', 'track_name', 'size_bytes', 'currency', 'price', 'rating_count_tot', 'rating_count_ver', 'user_rating', 'user_rating_ver', 'ver', 'cont_rating', 'prime_genre', 'sup_devices.num', 'ipadSc_urls.num', 'lang.num', 'vpp_lic', 'free_or_not']
['284882215', 'Facebook', '389879808', 'USD', '0.0', '2974676', '212', '3.5', '3.5', '95.0', '4+', 'Social Networking', '37', '1', '29', '1', 'free']
['389801252', 'Instagram', '113954816', 'USD', '0.0', '2161558', '1289', '4.5', '4.0', '10.23', '12+', 'Photo & Video', '37', '0', '29', '1', 'free']
The exactly same thing happens in the next screen, you just have more labels that you can use.
I hope I could help you now.
I’m sorry to give you the wrong information before. I think it looks better now.