Thursday, 23 June 2016

Generate Random String-Python

Today I am sharing a small piece of Python code to generate random string that i have wrote when i was just started Python Programming. The string will have only the characters: 0-9, A-Z, a-z.


import random
random_word = ''
for i in range(len_of_word):
    random_word += random.choice('ABCDPEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyz') 
print random_word

No comments:

Post a Comment