I get that it’s irresistible to copy and paste code from someone who says they’ve solved it for you. However, it’s not integrated into your exercise testing framework.
Maybe you could take this opportunity to read through the solution and see what each part means, and then think about how it should fit into the exercise file.
Also important in this particular case, it’s a good opportunity for you to figure out what really changed in the other poster’s snippet and think about why he considers that to solve the problem. It’s kind of subtle.
So go ahead and start off with this: line-by-line, what does the posted code do?
Having learnt that each step in coding is dependent on the previous one, I found that my difficulties grew rapidly as I attempted to progress through the course without a thorough grasp of a topic I still found unclear.
When you get stuck on a piece of homework, I recommend practicing by writing pseudo code for the question and posting it online for others to help you out. I believe you will receive more thorough assistance that will shed light on the issue you are having and reduce the likelihood that others will assume you are seeking a simple answer.
This is a pdf on writing pseudo-code. I’ve found a lot of the times, I would see the solution when I stepped back and just wrote out the code thinking about the concept.
It’s worth noting that I’m still very much a novice in the world of coding, so there may be more polished alternatives.