Skip to content

Instantly share code, notes, and snippets.

@rtacconi
Last active June 15, 2020 12:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rtacconi/fb45ac8be417ac0e665de8df08cb713b to your computer and use it in GitHub Desktop.
Save rtacconi/fb45ac8be417ac0e665de8df08cb713b to your computer and use it in GitHub Desktop.
In each input list, every number repeats at least once, except for two. Write a function that returns the two unique numbers.
def retun_unique(lst):
return [i for i in lst if lst.count(i) <= 1]
return_unique([1, 9, 8, 8, 7, 6, 1, 6]) # -> [9, 7]
return_unique([5, 5, 2, 4, 4, 4, 9, 9, 9, 1]) # -> [2, 1]
return_unique([9, 5, 6, 8, 7, 7, 1, 1, 1, 1, 1, 9, 8]) # -> [5, 6]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment