Saturday 15 September 2012

using a list of labels and a larger list to create a dictionary in Python -


Let me label = (a list of 'id', 'price', 'interest', 'bid', 'ask' Mill ',' wall '), then I have another list which can be any length, but to match the value of that list cycle to the order of the label.

In other words, I get a list of numbers: id, value, interest, quote, ask, volume ... repeat values, interstate, quote, ask, volume and on and until i values Does not go out of And as I have it repeated on those 5 numbers, I want to match 5 labels with one word which is close to the ID and then the id, I can see the price.

So, I do not think a zipper will work.

Thoughts?

Thank you!

In the rescue!

You need zip / izip and both.

  labels = ('value', 'interest', 'bid', 'ask', 'wall') list2 = ... # whatever you have itertools.izip (label, Itertools.cycle (list2))   

Well, zip / izip may not really be necessary that you What will ...

No comments:

Post a Comment