Created
August 14, 2020 05:01
-
-
Save Abidzar16/0505a073a5922cf842ed00e228a4a4c4 to your computer and use it in GitHub Desktop.
DE_Python soal nomor 1
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def unique_names(names1, names2): | |
names1 = list(dict.fromkeys(names1)) | |
names2 = list(dict.fromkeys(names2)) | |
names1.extend(x for x in names2 if x not in names1) | |
return names1 | |
names1 = ["Ava", "Emma", "Olivia"] | |
names2 = ["Olivia", "Sophia", "Emma"] | |
print(unique_names(names1, names2)) # should print Ava, Emma, Olivia, Sophia |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment