Please explain this code to me

duplicate_apps = []
unique_apps = []

for app in android:
    name = app[0]
    if name in unique_apps:
        duplicate_apps.append(name)
    else:
        unique_apps.append(name)
    
print('Number of duplicate apps:', len(duplicate_apps))
print('\n')
print('Examples of duplicate apps:', duplicate_apps[:15])

I’m confused as to how it sorts out the duplicate and unique apps when there’s nothing present in unique apps yet. According to the code, wouldn’t “app” be absent in both duplicate apps and unique apps when it enters the for loop?

A post was merged into an existing topic: I tried my own way to get duplicates but it’s giving me wrong answer