Skip to content

Instantly share code, notes, and snippets.

@spratt
Last active December 17, 2015 11:59
Show Gist options
  • Save spratt/5606658 to your computer and use it in GitHub Desktop.
Save spratt/5606658 to your computer and use it in GitHub Desktop.
randomly select from lines of input
#!/usr/bin/env python2.7
import random
from sys import stdin, argv
words = []
for line in stdin:
words.append(line.strip())
n = int(argv[1])
print(random.sample(words,n))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment