How to fill in a dictionary with key and value from a string?

C W tmrsg11 at gmail.com
Sun Apr 1 21:47:14 EDT 2018


I am using Python 3.6. I ran the those lines and got a sorted dictionary by
keys.

On Sun, Apr 1, 2018 at 9:38 PM, Chris Angelico <rosuav at gmail.com> wrote:

> On Mon, Apr 2, 2018 at 11:34 AM, C W <tmrsg11 at gmail.com> wrote:
> > A different but related question:
> >
> > myDict = dict(zip(string.ascii_lowercase + string.ascii_uppercase,
> > string.ascii_lowercase + string.ascii_uppercase))
> >>myDict
> > {'A': 'A', 'B': 'B', 'C': 'C',...,'w': 'w', 'x': 'x', 'y': 'y', 'z': 'z'}
> >
> > Why are the keys sorted from upper case to lower case? I asked for lower
> > case first, then upper case.
> >
>
> What version of which Python interpreter are you using? Dictionaries
> aren't sorted by definition, but sometimes they do retain order.
>
> ChrisA
> --
> https://mail.python.org/mailman/listinfo/python-list
>



More information about the Python-list mailing list