Advertisement
here2share

# only_remove_duplicates.py

Jan 7th, 2025
52
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.23 KB | None | 0 0
  1. # only_remove_duplicates.py
  2.  
  3. old = [99, 0, 5, 5, 4, 3, 5, 3, 2, 1]
  4. new = list(dict.fromkeys(old).keys())
  5. print(new, 'fromkeys(~) maintains the order')
  6.  
  7. # rather than...
  8. new = list(set(old))
  9. print(new, 'set(~) has changed the order')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement