lorde
lorde

Reputation: 6063

How would I go about randomly generating strings with certain parameters?

I want to create a program to randomly generate a string with this layout including dashes:

xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx

Now the limitations are to only include:

Using random Letters: a to f
Using random Numbers: 0 to 9
User input for how many times to print a random generated code on a new line.

I'm fairly new to programming and I would like some advice on how to approach this problem?

Upvotes: 0

Views: 59

Answers (1)

falsetru
falsetru

Reputation: 369064

Seems like you are generating uuid. use uuid:

>>> uuid.uuid4()
UUID('b80d8ad2-c0a5-4689-b39a-2c9869e906af')
>>> uuid.uuid4()
UUID('35895e08-8d72-4bda-9e6c-2a3dd4c2197c')
>>> uuid.uuid4()
UUID('fc3fb627-77e6-4598-9bf8-ac699b16d07a')
>>> uuid.uuid4()
UUID('f6b3fe86-429a-4acd-a509-aa687705bfca')

Upvotes: 2

Related Questions