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)

    

Comments

Popular posts from this blog

Quotation marks to wrap an element in HTML

The Basic Structure of a Full-Stack Web App

Unlocking Web Design: A Guide to Mastering CSS Layout Modes