My program generates a random string with a random amount of letters from 10 to 20.
def program():
import random
import sys
x=['q','w','e','r']
y=random.randint(10,20)
for t in range (0,y):
w=random.randint(0,3)
e=x[w]
sys.stdout.write(e)
The program will print a random string like 'wwwweewwqqrrrrwwqqeeqqww'. How would I store this string as a variable?
e = random.choice(x)is much more readable thanw = random.randint(0, 3); e = x[w].return ''.join(random.choices('qwer', k=random.randint(10, 20)))