1import random
2import string
3
4def randStr(chars = string.ascii_uppercase + string.digits, N=10):
5 return ''.join(random.choice(chars) for _ in range(N))
6
7# default length(=10) random string
8print(randStr())
9# random string of length 7
10print(randStr(N=7))
11# random string with characters picked from ascii_lowercase
12print(randStr(chars=string.ascii_lowercase))
13# random string with characters picked from 'abcdef123456'
14print(randStr(chars='abcdef123456'))