Back when I was learning programming a lot of lessons would make you do something like this, and then show you the real way to do it in the next lesson. My reaction was always “why didn’t you lead with this?”.
Because the point of the lesson is to demonstrate that you can solve the same problem multiple ways where some paths are more efficient than others.
Bad programmers are the ones that find the first solution and implement it no matter how inefficient it is.
Good programmers spend time on figuring out the solution with the least amount broken or inefficient code. You don’t learn this by jumping straight to the best answer every time.