Commit b4c40f23 authored by hydrargyrum's avatar hydrargyrum
Browse files

random-line: support file arguments and empty input

parent 00b7e00d
#!/usr/bin/env python
#!/usr/bin/env python3
# based on Fisher-Yates shuffle
# license: WTFPL
import random, sys
import fileinput
import random
import sys
for n, line in enumerate(sys.stdin):
choice = None
for n, line in enumerate(fileinput.input()):
if not random.randrange(n + 1):
choice = line
if choice is not None:
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment