John Fouhy wrote:
> On 29/08/07, Trey Keown <[EMAIL PROTECTED]> wrote:
>   
>> attrs={u'title': u'example window title', u'name': u'SELF', u'icon':
>> u'e.ico'}
>> keys = ['name','title','icon']
>> for (tag, val) in attrs.iteritems():
>>     for key in keys:
>>         print val
>>
>> the first "for" tag causes the dictionary (attrs) to have its keys called
>> "tag" and its value called "val". The second "for" loop causes the
>> dictionary keys to be read in a certain order. How could I take away the
>> first "for" loop and replace it with something else to do the same general
>> function?
>>     
>
> for key in keys:
>   print 'Attribute %s has value %s' % (key, attrs[key])
>
>   
Why even have the keys variable at all..

for key in attrs:
    print 'Attribute %s has value %s' % (key, attrs[key])



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

Reply via email to