import random
import string
def get_random_alphanumeric_string(length):
result_str = ''.join((random.choice(string.hexdigits) for i in range(length)))
print("Random alphanumeric String is:", result_str)
get_random_alphanumeric_string(8)
import random
import string
def get_random_alphanumeric_string(length):
letters_and_digits = string.ascii_letters + string.digits
result_str = ''.join((random.choice(letters_and_digits) for i in range(length)))
print("Random alphanumeric String is:", result_str)
get_random_alphanumeric_string(8)
get_random_alphanumeric_string(8)
import random
#String
string = "abcdefghijklmnopqrstuvwxyz"
array = []
for c in string:
array += [c]
print(array[random.randint(0, len(array)-1)])
# Faster and more efficient
random.choice(string)
# 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
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)