# for your eyes only
import random
import string
def get_random_string(length):
# choose from all lowercase letter
letters = string.ascii_letters
result_str = ''.join(random.choice(letters) for i in range(length))
print("The generated random string : " + str(res))
get_random_string(8)
import random
import string
# printing lowercase
letters = string.ascii_lowercase
print ( ''.join(random.choice(letters) for i in range(10)) )
# printing uppercase
letters = string.ascii_uppercase
print ( ''.join(random.choice(letters) for i in range(10)) )
# printing letters
letters = string.ascii_letters
print ( ''.join(random.choice(letters) for i in range(10)) )
# printing digits
letters = string.digits
print ( ''.join(random.choice(letters) for i in range(10)) )
# printing punctuation
letters = string.punctuation
print ( ''.join(random.choice(letters) for i in range(10)) )
how to generate string of random character in python
import random
import string
def get_random_string(length):
# choose from all lowercase letter
letters = string.ascii_lowercase
result_str = ''.join(random.choice(letters) for i in range(length))
print("Random string of length", length, "is:", result_str)
get_random_string(8)
get_random_string(6)
get_random_string(4)
from random import randint
def create_random_chars(nbr_of_chars):
return "".join(chr(randint(33,126)) for i in range(nbr_of_chars))
print(create_random_chars(10))
# I1CU>E5q;$