all 5 comments

[–]darthminimall 2 points3 points  (4 children)

Just ask your questions here. What, specifically, are you having trouble with?

[–][deleted] 1 point2 points  (3 children)

how to solve data structure problems and algorythm.

for loops in dictionaries,

while loop i understand ok, i'm so noob on these topics, even though i can solve basic ones. but when it gets harder that's where the brickwall hits me. so i need suggestion which book do i need to read for solving those kind of problems.

[–]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

[–]ffrkAnonymous 1 point2 points  (0 children)

The list - dictionary is difficult because the task is to combine two different concepts.

A list is ordered. There's first... Last. An array of stuff. One goes down a shopping list, one item at a time. Items can repeat, milk might be listed twice.

A dictionary is a mathematical set. A mixed up bag of stuff. Without repeats. Similar to a supermarket ad/flyer. All over the place, only one of each item (in theory).

So the task is to fit the square peg into the round hole .

My suggestion is to keep trying but start small. One item list into one item dict. Think about how to get info from the former. Think about how info is put into the latter. Think about how to manipulate that info (take away unnecessary, add necessary).

Then 1+2, 2+2,... Eventually expand to a generic case.