Skip to content

Commit a53cc1f

Browse files
committed
Merge pull request Show-Me-the-Code#105 from partrita/master
this is my first try
2 parents 82b05a1 + b7dc868 commit a53cc1f

2 files changed

Lines changed: 35 additions & 0 deletions

File tree

partrita/0001/codes.txt

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
VTGwsgMjVt4rXtS
2+
VcBNNj2wxpxzfIn
3+
tRkSWNZvlKtGZ9t
4+
GGfymamjpwD69rx
5+
vMGIGYdAPwIG5zT
6+
Mt60KsjdS6AdM4z
7+
SsTkjAOskJCH1SJ
8+
pG9w6OXJyNGNgu2
9+
er4a3ZxEg1XuX0g
10+
lIe85Mgl7Dg9aIh

partrita/0001/make_code.py

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# -*- coding: utf-8 -*-
2+
"""
3+
Created on Mon May 11 16:04:59 2015
4+
5+
@author: partrita
6+
"""
7+
8+
from random import Random
9+
10+
def codeGenerator(number, codeLength = 15):
11+
print '**** Code Generator ****'
12+
codeFile = open('codes.txt', 'w')
13+
if number <= 0:
14+
return 'invalid number of codes'
15+
else:
16+
chars = 'abcdefghijklmnopgrstuvwxyzABCDEFGHIJKLMNOPGRSTUVWXYZ1234567890'
17+
random = Random()
18+
for j in range(1, number+1):
19+
str = ''
20+
for i in range(1, codeLength+1):
21+
index = random.randint(1, len(chars))
22+
str = str + chars[index-1]
23+
codeFile.write(str+'\n')
24+
25+
print codeGenerator(10)

0 commit comments

Comments
 (0)