added random name generator
This commit is contained in:
parent
9c02c430f6
commit
ec099c84c9
26
13_random_name_generator.py
Normal file
26
13_random_name_generator.py
Normal file
@ -0,0 +1,26 @@
|
||||
from random import randint
|
||||
|
||||
|
||||
def random_name_generator(first, second, x):
|
||||
"""
|
||||
Generates random names.
|
||||
Arguments:
|
||||
- list of first names
|
||||
- list of last names
|
||||
- number of random names
|
||||
"""
|
||||
names = []
|
||||
for i in xrange(0, int(x)):
|
||||
random_first = randint(0, len(first)-1)
|
||||
random_last = randint(0, len(second)-1)
|
||||
names.append("{0} {1}".format(
|
||||
first[random_first],
|
||||
second[random_last])
|
||||
)
|
||||
return set(names)
|
||||
|
||||
|
||||
first_names = ["Drew", "Mike", "Landon", "Jeremy", "Tyler", "Tom", "Avery"]
|
||||
last_names = ["Smith", "Jones", "Brighton", "Taylor"]
|
||||
names = random_name_generator(first_names, last_names, 5)
|
||||
print '\n'.join(names)
|
@ -12,3 +12,4 @@
|
||||
1. **10_find_files_recursively.py**: recursively grab files from a directory
|
||||
1. **11_optimize_images_with_wand.py**: recursively grab images from a directory, then optimize them for the web
|
||||
1. **12_csv_split.py**: Splits a CSV file into multiple files based on command line arguments.
|
||||
1. **13_random_name_generator.py**: random name generator
|
||||
|
Loading…
Reference in New Issue
Block a user