Another python-dictionary question :)
here's my dictionary:
mydict = {key1: valueA, key2: valueA, key3: valueB, key4: valueA,
key5: valueA, key6: valueB, key7: valueB, key8: valueA, key9: valueB}
now i want to iterate through the dictionary only for the key-value-pairs of
key4
, key5
, key6
and key7
and check if the value is valueB
.
i hope it is possible to understand what i mean..
i want to create a for-loop, and only if the value of key4 is valueB, the content of the loop should be executed, then, if the value of key5 is valueB, it should be executed again, and so on. thanks in advance
for key in [key4, key5, key6, key7]:
if mydict[key] == valueB:
pass # do stuff here
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With