python-scripts/scripts/13_random_name_generator.py
uttamo 5b745282a9 Use random.choice instead of random.randint
random.choice is better for selecting random elements from a list than using random.randint to generate random indices to select
2017-09-28 01:02:29 +01:00

22 lines
579 B
Python
Executable File

from random import choice
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(x):
names.append("{0} {1}".format(choice(first), choice(second)))
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))