I'm trying to generate a wordlist using random module. The pattern I want is like this:
D7FE-PWO3-ODKE
I can generate the strings but I'm not able to figure out how can I get that hyphen (-) between them.
import random
import string
wordlist = string.ascii_uppercase + string.digits
def random_string(len):
    for i in range(10):
        result = ''.join(random.choice(wordlist) for _ in range(len))
        print(result)
random_string(12)
I have tried this approach but this gives whitespaces after each (-).
def random_string():
    
    for i in range(10):
        str1 = ''.join(random.choice(wordlist) for _ in range(4)) + '-'.strip()
        str2 = ''.join(random.choice(wordlist) for _ in range(4)) + '-'.strip()
        str3 = ''.join(random.choice(wordlist) for _ in range(4))
        print(str1, str2, str3)
random_string()




.strip()?print(str1, str2, str3, sep='')should workprintinserts spaces between it's arguments. Usestr1 + str2 + str3str1 = ''.join(random.choice(wordlist) for _ in range(4)) + '-'.strip(), why did you not instead writeprint(''.join(random.choice(wordlist) for _ in range(4)), '-')? Clearly you know how to create a string that doesn't have spaces in it, so if you want to make a longer string that doesn't have any spaces, using those pieces... just do the same thing again? What exactly is the issue?