I want to create a code that would generate number of random strings (for eg.10 in this case). I used the code below but the code kept on generating same strings
Input Code
import random
import string
s = string.ascii_lowercase
c = ''.join(random.choice(s) for i in range(8))
for x in range (0,10):
print(c)
Output
ashjkaes
ashjkaes
ashjkaes
ashjkaes
ashjkaes
ashjkaes
ashjkaes
ashjkaes
press any key to continue .....
Please help
What you do now is you generate a random string c then print it 10 times
You should instead place the generation inside the loop to generate a new string every time.
import random
import string
s = string.ascii_lowercase
for i in range(10):
c = ''.join(random.choice(s) for i in range(8))
print(c)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With