python-scripts/scripts/13_random_name_generator.py

27 lines
729 B
Python
Raw Normal View History

2014-06-02 21:08:53 +02:00
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 range(0, int(x)):
2014-06-02 21:08:53 +02:00
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))