The words Under construction in black text on a yellow background with diagonal black stipes surrounding it
I'm in the process of moving my site. It's still a work in progress. Please excuse the mess and broken links.

Automatically Generate A List With The English Alphabet In Python

TODO: Pull subtitle into page object

TODO: Combine with: 264g8rgi1kbj which shows how to get a subset of letters.

TODO: Setup a function where you can pass a letter and a number of letters to add and produce a list from that. -- hr

Sometimes you want to get your hands on all the letters in the english alphabet. Here's how:

** Lowercase

You can generate a list of with the full alphabet of lowercase english letters using:

Code
import string

alphabet_lowercase = list(string.ascii_lowercase)

print(alphabet_lowercase)
Results
['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']

** How It Works

The `string.ascii_lowercase` and `string.ascii_uppercase` calls each return single strings with their correspondingly cased alphabets. That is, `abcdefghijklmnopqrstuvwxyz` and `ABCDEFGHIJKLMNOPQRSTUVWXYZ`, respectively.

Wrapping a string in `list()` splits each character out individually and returns it as a separate item in a list.

So, calling `list(string.ascii_lowercase)` is equivalent to calling `list('abcdefghijklmnopqrstuvwxyz')` which does the split and generates our list `['a', 'b', 'c', ...etc ]`

`string.ascii_lowercase` and `string.ascii_uppercase` are "String Constants". Basically, built-in stuff that does't change (even if the locale does TKTKTKT note what locale is).

There are a few other String Constants for digits and punctuation that you can

Debugging Stuff

I'm moving stuff around right now. All this below is helping me figure out where to put stuff

        -- title

Automatically Generate A List With The English Alphabet In Python

-- p

TODO: Combine with: 264g8rgi1kbj which shows how to get a
subset of letters.

-- p

TODO: Setup a function where
you can pass a letter and a number of letters to add
and produce a list from that.
-- hr

-- p

Sometimes you want to get your hands on all the
letters in the english alphabet. Here's how:

-- p

** Lowercase

-- p

You can generate a list of with the full alphabet
of lowercase english letters using:

-- code
-- python

import string

alphabet_lowercase = list(string.ascii_lowercase)

print(alphabet_lowercase)

-- results/

['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']

-- /results


-- p

** Uppercase

-- p

Uppercase letters can be had with:

-- code/
-- python

import string

  alphabet_uppercase = list(string.ascii_uppercase)

  print(alphabet_uppercase)

-- /code

-- results/

['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']

-- /results

-- p

** How It Works

-- p

The `string.ascii_lowercase` and `string.ascii_uppercase`
calls each return single strings with their correspondingly
cased alphabets. That is, `abcdefghijklmnopqrstuvwxyz` and
`ABCDEFGHIJKLMNOPQRSTUVWXYZ`, respectively.

-- p

Wrapping a string in `list()` splits each character out
individually and returns it as a separate item in a list.

-- p

So, calling `list(string.ascii_lowercase)` is equivalent
to calling `list('abcdefghijklmnopqrstuvwxyz')` which
does the split and generates our list `['a', 'b', 'c', ...etc ]`

-- p

`string.ascii_lowercase` and `string.ascii_uppercase`
are "String Constants". Basically, built-in stuff that
does't change (even if the locale does TKTKTKT note
what locale is).

-- p

There are a few other String Constants for digits
and punctuation that you can
<a href="https://docs.python.org/3/library/string.html">check
out in the docs</a>.


-- categories
-- Python 

-- metadata
-- date: 2022-03-07 11:48:36
-- id: 2648u0ur
-- status: draft 
-- type: post
-- SCRUBBED_NEO: false
-- site: aws