5b745282a9
random.choice is better for selecting random elements from a list than using random.randint to generate random indices to select
22 lines
579 B
Python
Executable File
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))
|