python - Generate two random strings with dash in between -


i wondering how make code in python 3.4.3 can generate 2 3 character long strings. 1 digits 0 - 9, , other capital letters of alphabet. there has dash between them.

examples:

mus-875  kle-443  ami-989 

this have

from random import randint  print(randint(2,9)) 

try picking random string of letters, random string of digits, joining them hyphen:

import string, random def pick(num):     j in range(num):         print("".join([random.choice(string.ascii_uppercase) in range(3)])+"-"+"".join([random.choice(string.digits) in range(3)])) 

as such:

>>> pick(5) osd-711 krh-340 mde-271 zjf-921 lux-920 >>> pick(0) >>> pick(3) sft-252 xsl-209 maf-579 

Comments

Popular posts from this blog

How to run C# code using mono without Xamarin in Android? -

c# - SharpSsh Command Execution -

python - Specify path of savefig with pylab or matplotlib -