Re: [Tutor] Weird iteration using zip()

2005-10-27 Thread Alan Gauld
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 t

Re: [Tutor] Weird iteration using zip()

2005-10-27 Thread Kent Johnson
Srinivas Iyyer wrote: > Hi all: > > Here is a simple code: > > 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" The order of keys in a dict is effectively indeterm

[Tutor] Weird iteration using zip()

2005-10-27 Thread Srinivas Iyyer
Hi all: Here is a simple code: >>> 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" Why not: >>> abdict {'a':1,'b':2,'c':3,'d':4,'e':5} Is there any hidden logic in the code that