Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #Credits: LOLDONGS : http://pastebin.com/u/loldongs
- Here is a very simple, 1 line function, to return a random string of characters, of any given length you specify.
- ##################################################
- #IMPORTS
- import random
- #GET RANDOM
- def getRandom(length): return ''.join(random.sample('abcdefghijklmnopqrstuvwxyz', length))
- ##################################################
- You would call this by using an integer for the "length" argument. For example :
- variable = getRandom(20)
- print(variable)
- 'uedxkcygka'
- NOTE: This only returns a random string using lowercase letters. You can easily modify it to use whatever characters you want.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement