uplicate_apps = 
unique_apps = 
for android_app in android:
name = android_app
if name in unique_apps:
print('Duplicate apps:', len(duplicate_apps))
print('Examples of duplicate apps:', duplicate_apps[:15])
What I expected to happen:
I did not understand why we need to write name=i and how it works
Hello @handepehlivan1 welcome to the community.
android_header, contains a list of the column names. If you use indexing to see the item on position
android_header, it is
App, which is the name of the app.
Similarly, when you take the same index position on
andriod, you are referring to the name of the app.
andriod is a list containing lists, so when I take the first list and take the item on the first position on the list,
andriod, the name of the app is
Photo Editor & ...
name = android_app means assigned the name of the app to the variable
if name in unique_apps checks if it is in the list
unique_apps. If it is indeed in
unique_apps, append the name of this app to
Else append it to
unique_apps (because the name of this app was not found in the list of unique_apps so it is not a duplicate).
Please check out these guidelines for asking good questions.
Firstly, thank you for your reply. So I understand name = android_app take the index position on android
. Throughout the code is it go to the 1,2… , n position in android ?
if it is, is it only store 1 element in the android app, so they call android_app?
What the code here intends to do is check if an app was stored more than one times on the list. So you do so with the name of the app. You iterate over the rows and check if the name of the app is unique or not.
You iterate over the list of list with
for android_app in android.
For every new list called
andriod_app, take the first position, index 0, and assign what you find ther to the variable
name. So the
name changes for every iteration. You check this
name against your
unique_apps list each time to find out if it is already in the list:
if name in unique_apps
This is one list:
alist = ['A', 10, 3.5'].
alist = A
This is a list of list:
[['A', 10, 3.5], ['B', 5, 2.5], ['C', 2, 1.3]]
You move like this:
andriod_app = ['A', 10, 3.5] and assign name = andriod_app = 'A'
andriod_app = ['B', 5, 2.5] and assign name =andriod_app = 'B'
andriod_app = ['C', 2, 1.3] and assign name = andriod_app = 'C'