0

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?

1
  • Please post what you've tried (actual code is preferable to just verbal descriptions) and explain where you ran into problems.
    – Adi Inbar
    Commented Aug 11, 2013 at 3:20

1 Answer 1

2

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')
3
  • How would I just get the code from within the UUID(' ') and assign that to a variable?
    – lorde
    Commented Aug 11, 2013 at 3:10
  • Don't worry, got it! a = uuid.uuid4() str(a)
    – lorde
    Commented Aug 11, 2013 at 3:11
  • @lorde, str(uuid.uuid4())
    – falsetru
    Commented Aug 11, 2013 at 3:11

Not the answer you're looking for? Browse other questions tagged or ask your own question.