0

Can you guys help me in shortening my code ?

https://code.sololearn.com/caivJFm99oz6/?ref=app

1st May 2020, 1:03 PM
Albert
Albert - avatar
3 Respuestas
+ 1
I have shortened it a bit. Please ask if you don't understand one of the changes. from random import choice a = "abcdefghijklmnopqrstuvwxyz" a += a.upper() b = "0123456789" c = "!@#
amp;" d = "" for i in range(4): d += choice(a) for i in range(4): d += choice(b) for i in range(4): d += choice(c) print(d)
1st May 2020, 1:48 PM
HonFu
HonFu - avatar
+ 1
import random import string mychars, mynumbers, mysymbols = string.ascii_letters, string.digits, "!@#
amp;" d = ''.join(random.choices(mychars, k=4) + random.choices(mynumbers, k=4) + random.choices(mysymbols, k=2)) print(d)
1st May 2020, 5:48 PM
rodwynnejones
rodwynnejones - avatar
0
Thanks Honfu
1st May 2020, 1:51 PM
Albert
Albert - avatar