In addition to @l0b0's answer:
To generate cryptographically secure random strings (since this is a toy project, why not use a CSPRNG? it's a useful thing to learn):
import string
# only needs to be initialized once
import random
csprng = random.SystemRandom()
# alternatively, the "secrets" module is meant for generating strong csprng numbers
import secrets
csprng = secrets.SystemRandom()
# uses @Graipher's suggestion of .choices()
def random_string(len = 3, charsets = string.ascii_lowercase):
return ''.join(csprng.choices(charsets, k = len))
three_letter_strings = [random_string() for _ in range(10)]
print(three_letter_strings)
"""
example output:
['ebi', 'hbg', 'hlm', 'rhp', 'eka', 'uja', 'uhi', 'lju', 'vvf', 'qtj']
"""
"""
alternatively, below is likely faster
if you want to do this a lot more than 10 times
see: https://stackoverflow.com/a/2970789
"""
import itertools
three_letter_strings = [random_string() for _ in itertools.repeat(None, 10)]
print(three_letter_strings)
Tested with Python 3.6.5