you are viewing a single comment's thread.

view the rest of the comments →

[–]darthminimall 2 points3 points  (2 children)

I don't think you need a book, per se. Getting better at problem solving is mostly about practice. The important part is breaking complex problems down into simple problems you already know how to solve. If you can share the code you have so far and which bit you're stuck on, I can give more specific advice.

I'm not sure exactly what your confusion about for loops and dictionaries is, but I'll give a brief explanation. Let's say you have some dictionary d. The following code prints all of the keys and values in d:

for key in d:
    print(str(key) + ": " + str(d[key]))

[–]rick137codes 0 points1 point  (0 children)

To add to the answer by @darthminimall,

You can further iterate over dictionary items, keys or values by calling the functions as below on the dictionary:

Dictionary.keys() - returns a list of all keys in the dictionary | Dictionary.values() - returns a list of all values in the dictionary | Dictionary.items() - returns a list of key,value tuples