issues with searching through dictionaries for certain values

Sion Arrowsmith siona at chiark.greenend.org.uk
Fri Feb 1 10:35:07 EST 2008


Connolly <cho.hatred at gmail.com> wrote:
>Right basically I've got to the end of my main section of my program an I've 
>got it comparing the same dictionary to ensure that the values are the same 
>(sounds stupid I know), yet what my line of code I am using to do this is 
>failing to do is to check every single value. It is only checking the final 
>value in my dictionary [ ... ]

On what are you basing the assumption that it's only checking the
final value? The outputted final_dict? Have you tried putting a
"print final_dict" after the final_dict.update() call to see how
many times the check is actually made? And while your doing that,
you might like to stick in a "print f6" at the same place, and see
how many different values are being added to final_dict.

(I assume there is good reason which has been cut out for
f6 = {start+1: key}
final_dict.update(f6)
rather than
final_dict[start+1] = key
)

>f4 = files_stored[0]
>f5 = files_stored[0]
>
>for key in f4:
>    for items in f5:
>        if key == items:
>            f6 = {start+1: key}
>            final_dict.update(f6)
>        else:
>            print key, 'false'
>
>print final_dict

-- 
\S -- siona at chiark.greenend.org.uk -- http://www.chaos.org.uk/~sion/
   "Frankly I have no feelings towards penguins one way or the other"
        -- Arthur C. Clarke
   her nu becomeþ se bera eadward ofdun hlæddre heafdes bæce bump bump bump



More information about the Python-list mailing list