Posts

Showing posts with the label random module

Generating Random Alphabet in Python

There are two ways to generate a random alphabet in python. The first method uses string and random modules. import string import random randomAlphabet = random.choice(string.ascii_letters) print(randomAlphabet) The second method uses random module only. import random randomCharacter = chr(random.randint(ord("a"), ord("z"))) print(randomCharacter)