Categories
How to generate a string of this format in python?
Greetings! Tell me how to generate such a string with random values: uppercase English letters and numbers 0-9 Format: XXXX-XXXX-XXXX-XXXX-XXXX
Answer the question
In order to leave comments, you need to log in
from random import choice chars = '0123456789abcdefghijklmnopqrstuvwxyz' section_size = 4 sections_num = 5 string = '-'.join(''.join(choice(chars) for j in range(section_size)) for i in range(sections_num))
Didn't find what you were looking for?
Ask a Question
731 491 924 answers to any question