Created
July 28, 2020 13:59
-
-
Save FerdinaKusumah/bf6201426c9e6621039ab55637f804bc to your computer and use it in GitHub Desktop.
[Python] remove duplicate
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
from collections import OrderedDict | |
"""remove duplicate""" | |
num = [9, 9, 8, 7, 1, 3, 5, 3, 4, 7, 8, 2] | |
"""if order is not important""" | |
unique_sort_num = list(set(num)) | |
# [1, 2, 3, 4, 5, 7, 8, 9] | |
"""if order is important""" | |
unique_num = list(OrderedDict.fromkeys(num).keys()) | |
# [9, 8, 7, 1, 3, 5, 4, 2] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment