Nested for Loops gives me error everytime

Hi, I have a little problem here. No matter what I do, I’m getting error. Below is my code which is (at least I think) corrent. The thing is, it gives me an error even when I use the “solution” code. I’ve tried everything, refreshing my browser too. Please help me. I’m getting so frustrated that I might be done for today. This is so stupid. I just hope that the problem is in me and not some stupid bug. Please help, anyone… If I’m asking for help, that means I’m desperate.
Not sure if the picture is gonna show right away or it will be just a link, I’ll try fix it right when I post this.

This is my code:

And this is the “solution” code:
(sorry, I’m new at the forum so i cannot post more than one image)

When I’m over-reaching and can’t reason about something I take a few steps back to something trivial that I can deal with and can build on.

How about a loop which counts up from 0 to 5, which prints each number
And then count up to the length

You can comment out the current code. At the very least it’s useful for comparing later.

Observing the effects of what you write is also important. It doesn’t prove correctness, but it shows what currently happens at least. That’s why I suggest printing the current number. If you for example print nothing at all, or the wrong number of times then that is information you can use.

Oh and, those exercises don’t care much about how something behaves, they look at what you wrote - you’re at the mercy of the author’s imagination. You’ll want to remove the print once you have it working like you want since the instructions don’t ask for anything to be printed

Ok, so… I did the “loop count” thing. But I still don’t know.

The problem is, that I am so sure about this. I don’t see the error I did in my code. It’s the first time I’m stuck. And I feel like it’s not my fault.

Please tell me. Is there something wrong with my code why it’s not working? Don’t tell me what, just tell me, that there is something. I can accept that and try to do it right, no matter how long it takes. But if there is some bug which is not my fault… I just wanna know. Please.

I don’t even want to answer that when you can test that yourself by printing out the count that the loop is doing.

Up until you’ve observed that your code does what you mean, you may as well ignore anything codecademy has to say.

If you do observe that your code does what you mean, and that isn’t being accepted, that’s when it’s time to look for nit-picky details being off. But you’re not there yet since you haven’t made that observation!

I am so stupid. Like for real, I’m so disgusted of myself. I can’t even read properly. And the worst thing is, this isn’t the first time. Can we pretend like this never happend?

It’s working. Of course. Thanks for quick answers.

I want to crawl back into my cave and die in shame.

codecademy’s response is incorrect. And this is because they comment on behaviour but that’s not what they test for. (And I’m not a fan of that)

But there was your own testing to do. There were things to go on. It may not be particularly obvious what to look at next, that’s fine. Having a look at what happens is probably the right response in most cases. A couple prints can do a lot to show what happens.

I can delete the thread if you like.

Oh and you shouldn’t expect to notice when there’s a typo somewhere (or other small mistake)
There might be a lot of code. If anything, expect to make mistakes. And expect to have to go back to find and fix them.
One has to reason about what’s going on and narrow it down instead.

You’re absolutely right. And you can bet that I’m gonna learn from today. It was horrible. Our mistakes are our best teachers, I guess.

Thanks again!

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.