First time poster. Been at python about 2 weeks now.
As part of a larger challenge (that I have mostly solved) I need to print every other keypair in a dictionary.
The way I thought about this was looping through the dictionary with an index method and then trying to use % to tell if it was even or odd. If it was odd I would just append it to a new variable.
I am having all kind of issues and getting cryptic error messages.
Here is the snippet I am playing around with, right now just trying to get the index to compare and make sure that works before I loop through the dictionary:
Expand|Select|Wrap|Line Numbers
- for a in letlist:
- a = (letlist.index)
- int(a)
- if ((a % 2) != 0):
- print (a)
I have tried several different permutations and get errors on all. It is almost as if I can't do anything with a because I used it somewhere else.
Any help appreciated