Setup

This import is needed for the rest of this page. Load the built-in string module.

import string

ASCII

>>> string.ascii_lowercase
'abcdefghijklmnopqrstuvwxyz'
>>> string.ascii_uppercase
'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
>>> string.ascii_letters
'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'

Numbers

>>> string.digits
'0123456789'

Mix like this:

>>> string.ascii_uppercase + string.digits
'ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789'

Punctuation

>>> string.punctuation
'!"#$%&\'()*+,-./:;<=>?@[\\]^_`{|}~'

Whitespace

>>> string.whitespace
' \t\n\r\x0b\x0c'

Printable

Numbers, ASCII, puncutation, and whitespace.

>>> string.printable
'0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ!"#$%&\'()*+,-./:;<=>?@[\\]^_`{|}~ \t\n\r\x0b\x0c'

String to list

>>> letters_str = string.ascii_uppercase + string.digits
>>> letters_str
'ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789'
>>> letters_list = list(letters_str)
>>> letters_list
['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 
 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9']