On Wed, Dec 4, 2013 at 8:13 PM, Jared Nielsen <[email protected]>wrote:

> I want to create a dictionary, assign it keys, then iterate through a for
> loop and assign the dictionary values from a list. I'm trying this, but
> it's not working:
>
> dictionary = {"one", "two", "three"}
> list = [1,2,3]
>
>
Hi Jared,

'dictionary' here is misnamed in the program: it's not a dictionary that
you've constructed here, but a 'set'.  Sets and dictionaries in Python
unfortunately use very similar syntax, which leads to this confusion.

Try:

    dictionary = {}

Start with that.  You can then say things like:

    dictionary["one"] = 1

Read:

    http://docs.python.org/3.3/tutorial/datastructures.html#dictionaries

for a few more examples with dictionaries.
_______________________________________________
Tutor maillist  -  [email protected]
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor

Reply via email to