Well, no one has answered, so I’ll give it a whack. (Keep in mind, I don’t know Python.)
Yes, learning take the tools that we’ve learned and to break these things into small steps and work through it.
The first thing is to understand that algorithms are not computer programming. An algorithm is not tied to a specific programming language or any programming language. If an alien asked me “What is a fool proof method for finding the right page in the dictionary for a specific word?” I would say:
- Open up halfway through the book, essentially dividing it into two sections
- See if the word you need comes before that page or after.
- If the word comes before, the “before” section is your new section, if it comes after, the “after” section is your new section.
- Go back to step 2 with your new section and repeat until you’ve divided it down to one section.
That is an algorithm, it is a process for solving a problem. This specific algorithm is called a binary search. How you implement that in every computer language will be slightly different, but the algorithm itself is language agnostic.
The other thing to know is that algorithms are hard - they take time to learn. The more you learn, the easier they get. Also, it is only a part of being a good programmer - don’t obsess about it. Just keep working at it - it will come.
What are the steps to this problem? Sit down and think it out. If you can write them out, even better - don’t worry about the specifics of Python, just write out the process. Some people then use pseudo-code, sort of a loose code that looks like a computer language, but isn’t strict. Being able to mentally conceive of the process is 80% of the problem.
Seriously, do that know. Reread the instructions, look at your input data, look at your desired data, and then figure out the steps. Again, don’t worry about Python.
I have an idea in my head but I want to let you figure it out.
I will say that:
print (" ", global_list, global_list, ...
I don’t think that is going to work. How will you know how many math problems there are? When you have a list like that and you don’t know how many there are, usually you have to use a loop.
But take a second, think it out. Write out what you think the process is. Don’t worry about using the “perfect words”, just write out a process. Let us see what you come up with.