Skip to content

Instantly share code, notes, and snippets.

@kbambz
Last active November 29, 2015 03:42
Show Gist options
  • Select an option

  • Save kbambz/435081215f42f3c7e970 to your computer and use it in GitHub Desktop.

Select an option

Save kbambz/435081215f42f3c7e970 to your computer and use it in GitHub Desktop.
import random
def unique(values):
return list(set(values))
def choose_n(values, n):
assert len(values) <= n
return random.sample(values, n)
def main():
words = [u'some', u'word', u'list', u'list']
print(choose_n(unique(words), 3))
if __name__ == '__main__':
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment