On Aug 13, 2007, at 3:13 PM, Jeff Johnson wrote:
> Ed: "for pos, denom in denominations:" gave me a "type error -
> unpacking
> non-sequence" so I changed it to:
>
> "for pos in range(len(denominations)):" and it worked.
>
> I am using Python 2.5.
My bad: I wrote it one way to test, and then re-wrote it from memory
into the email (with real var names instead of x, y and such).
The missing thing is the enumerate() function. It returns a 2-tuple:
the iteration (starting with zero), and the item in the list. So
change the code to:
for pos, denom in enumerate(denominations):
The enumerate function is very useful, as it eliminates the need for
managing a counter variable.
-- Ed Leafe
-- http://leafe.com
-- http://dabodev.com
_______________________________________________
Post Messages to: [email protected]
Subscription Maintenance: http://leafe.com/mailman/listinfo/dabo-users
Searchable Archives: http://leafe.com/archives/search/dabo-users
This message: http://leafe.com/archives/byMID/dabo-users/[EMAIL PROTECTED]