Quantcast
Channel: print dictionary minus two elements - Stack Overflow
Viewing all articles
Browse latest Browse all 3

print dictionary minus two elements

$
0
0

Python 3.6

All debug output is from PyCharm 2017.1.2

I have a program that gets to this portion of the code:

if len(errdict) == 21:    for k, v in errdict.items():        if k == 'packets output' or 'bytes':            continue        print(k, v)    print()

The values of k: and errdict{} at the time of execution are as follows:

k={str}'input errors'__len__ = {int} 21'CRC' (73390624) = {int} 0'babbles' (73390464) = {int} 0'bytes' (73390496) = {int} 0'collisions' (73455360) = {int} 0'deferred' (73455440) = {int} 0'frame' (73390592) = {int} 0'ignored' (73390688) = {int} 0'input errors' (73455280) = {int} 0'input packets with dribble condition detected' (63021088) = {int} 0'interface resets' (73451808) = {int} 0'late collision' (73455400) = {int} 0'lost carrier' (73455520) = {int} 0'no carrier' (73455480) = {int} 0'output buffer failures' (73451856) = {int} 0'output buffers swapped out' (73055328) = {int} 0'output errors' (73455120) = {int} 0'overrun' (73390112) = {int} 0'packets output' (73455320) = {int} 0'underruns' (73455080) = {int} 0'unknown protocol drops' (73451904) = {int} 0'watchdog' (73455160) = {int} 0

If I remove these two lines:

        if k == 'packets output' or 'bytes':            continue

it correctly prints out all 21 key\value pairs of the dictionary. I want all of the dictionary to print EXCEPT the two key\value pairs that have 'packets output' or 'bytes' as the key.

With those two lines every key\value pair is skipped over and nothing prints. I simply do not see why. 'input errors' does not match my condition, so the continue should be skipped and it should print, and so on down the line except for the two keys that do match and they should be skipped.

What am I missing?

Thank you.


Viewing all articles
Browse latest Browse all 3

Trending Articles