diff --git a/13_random_name_generator.py b/13_random_name_generator.py new file mode 100644 index 0000000..0719eec --- /dev/null +++ b/13_random_name_generator.py @@ -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) diff --git a/readme.md b/readme.md index 9a3a727..44c9970 100644 --- a/readme.md +++ b/readme.md @@ -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