Arrays: Problem appears to be a bug in the lesson?


#1

This is the code - demo_array = [100, 200, 300, 400, 500]

Instructions

Use square bracket notation to print the third value of demo_array to the console.

Remember that the third value is at index two, not at index three. We start counting indices from zero.

Hint

Remember, you can access the ith value of an array with

array_name[i]

I put: demo_array[2] - and it even prints out the 300 in index 3 of the array on the console!

This is the error message:
Oops, try again. It looks like you didn't print anything to the console.

What does anyone think about this?


#2

Hi @jason1560,

Did you use the print command?


#3

No, I used array[2] to display the third element of the array, which was 300, and it displayed it in the console, yet I was still getting the error message. It's not really a big deal because I've already been through that lesson and can just skip over it to the next one. I was going to say it may be my browser, but I tried both firefox and chrome. So I don't know what the problem is. I experience odd glitches, from time to time, where I have to reload the page, and the lesson I'm working on will work, but not this time, so I don't know. But like I said, it's not that big of a deal because I've already been over that lesson and can just skip over it.


#4

Hi @jason1560,

As I said before, here are the exercise instructions:

Use square bracket notation to print the third value of demo_array to the console.

The exercise wants you to use the print command.

But I am still seeing the output without print??

That's technically not the "printed" output, but the return value of your program. So, for example if you wrote:

demo_array[2]
5 # add this line

then you will see 5 as the output - which is the return value of the last statement of your program, and the output 300 you were earlier getting is lost. If you were printing the demo_array[2] above, like this:

print demo_array[2]
5 # add this line

then, you would see both the 300 as well as the return value which is 5.

Hope it helps! :slightly_smiling: