Quote:I am trying to find every other value in a dictionary.Do you mean a list? As this doesn't make much sense for a dictionary.
If you mean a list, the easiest way is slicing:
>>> my_list ['a', 'b', 'c', 'd', 'e', 'f', 'g'] >>> my_list[::2] ['a', 'c', 'e', 'g'] >>> for letter in my_list[::2]: ... print(letter) ... a c e g >>>Edit:
Okay realized that was a typo and you mean even/odd.
You have basically the right idea:
>>> my_list [6, 9, 8, 3, 5, 1, 10, 10, 4, 6] >>> for num in my_list: ... if num % 2: ... print(num) ... 9 3 5 1 >>> [num for num in my_list if num % 2] [9, 3, 5, 1] >>>