On 25/02/2011 9:44 AM, Patty wrote:
----- Original Message -----
*From:* Pacific Morrowind <mailto:pacificmorrow...@gmail.com>
*To:* tutor@python.org <mailto:tutor@python.org>
*Sent:* Thursday, February 24, 2011 10:21 PM
*Subject:* Re: [Tutor] list of dictionary
<snip>
Presuming you do have to use the dictionaries:
qty = 0.0
for item in d:
Right here - is the variable 'item' created right on the spot to
iterate over this list? And I think you are doing the same thing
when you create the variable 'subitem' in the line below, right?
I am trying to get myself to recognize an iterator variable as
opposed to a counter variable I create myself to keep track of
these things (used in other programming languages) - and realizing
the difference between counter/iterator variables and variables
that I really care about like
'd = []' .
Thanks!
Patty
yes and yes. both item and subitem are created on the spot; anychunk of
python code like:
for x in y:
will create x as a variable and with each iteration x refers to the next
item in y;
Of course if I knew the function of the list/dictionary I'd name them
something more informative than item and subitem - like f.e. for lap in
d and for time in d if it was refering to races.
Nick
_______________________________________________
Tutor maillist - Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor