+ 1

Can we generate random strings in python by using random module? Please also read description to know more.

As we can generate random number using randint function but can we generate a random strings from given strings in Python.

7th May 2020, 3:48 PM
Yash Tyagi
Yash Tyagi - avatar
3 ответов
+ 2
Yes import random as r letters = [a,b,c,d,e] for lett in range(5): print(r.choice(letters),end='') Gives you a 5 letter word with random characters from the list. It wont actually mean anything though... Also think of the letters list as a split string if that helps
7th May 2020, 3:55 PM
Slick
Slick - avatar
+ 2
Not quite clear to me, what you expected to get. Is it that "playground" should be mixed up like "slrnoeaol"? Any further explanation or sample will be helpful. Thanks!
7th May 2020, 4:59 PM
Lothar
Lothar - avatar