DEV Community

Discussion on: Simplest Python Random Password - with only 6 lines of code

Collapse
 
jonrandy profile image
Jon Randy 🎖️
"".join(random.choices(string.ascii_letters + string.digits + string.punctuation, k=random.randint(12, 15)))
Enter fullscreen mode Exit fullscreen mode
Collapse
 
hammertoe profile image
Matt Hamilton

This is what I love about stumbling upon random stuff like this. I've been a Python developer for two decades, and yet had no idea that random.choices (the plural) existed. Looks like it came in 3.6. Thanks!