>>>> a = ['a','b','c','d','e']
>>>> b = [1,2,3,4,5]
>>>> abdict = dict(zip(a,b))
>>>> abdict
> {'a': 1, 'c': 3, 'b': 2, 'e': 5, 'd': 4}
> 
> 
> Why is this weird iteration going on"

Dictionaries store their values in the most efficient way for key lookup 
they do not store them in order. In fact the order can even change 
over the life of the dictionary. Think of a dictionary being like a tree 
rather than a list.

This is also why accessing data from a dictionary is often faster 
than from a list.

Alan G
Author of the learn to program web tutor
http://www.freenetpages.co.uk/hp/alan.gauld


_______________________________________________
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor

Reply via email to