From: Colin Patrick McCabe Date: Thu, 3 Mar 2011 22:46:12 +0000 (-0800) Subject: pickrand.py: fix off-by-one X-Git-Url: http://club.cc.cmu.edu/~cmccabe/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=53a5d21db29dcd910e5b256255ef6ed776497c0d;p=cmccabe-bin pickrand.py: fix off-by-one Signed-off-by: Colin McCabe --- diff --git a/pickrand.py b/pickrand.py index 8253e74..9efec59 100755 --- a/pickrand.py +++ b/pickrand.py @@ -12,6 +12,6 @@ for root, dirs, files in os.walk(".", followlinks=True): if (len(allfiles) == 0): sys.exit(1) random.seed(None) -r = random.randint(0,len(allfiles)) +r = random.randint(0,len(allfiles) - 1) print(allfiles[r]) sys.exit(0)