mercredi 4 juillet 2018

How to generate sequence of letters in python?

Is there any way to generate random alphabets in python. I've come across a code where it is possible to generate random alphabets from a-z.

For instance, the below code generates the following output.

import pandas as pd
import numpy as np
import string

ran1 = np.random.random(5)
print(random)
[0.79842166 0.9632492  0.78434385 0.29819737 0.98211011]

ran2 = string.ascii_lowercase
'abcdefghijklmnopqrstuvwxyz'

However, I want to generate random letters with input as the number of random letters. Thanks in advance.




Aucun commentaire:

Enregistrer un commentaire