Bracket Square Notation


#1



Replace this line with your code.


#2

Been trying to get the third value of the array and an error keeps coming up...Make sure you use square bracket notation to pick out the third element.
my code is
demo_array=[5,10,15,20,25,30]
print demo_array[2]

what could be the problem


#3

Well, that looks right, but perhaps you're doing something else slightly different, renaming the array or some such. The conditions in the submission tests often don't exactly match the messages they give. (like assuming that if there is smoke then there is fire, bad assumptions)

If you give me a link to the exercise then I'm confident that I can find what it is really bothered by, but see if you can't find any such differences yourself just by comparing instructions to code/what you've done.


#4

https://www.codecademy.com/courses/ruby-beginner-en-F3loB/0/2?curriculum_id=5059f8619189a5000201fbcb#


#5

It is looking for:

demo_array[

In your code. That's what you showed me, which makes me think you ran something else.

So, what you can do next is
1) make sure you really ran that code, and that the above is somewhere in your code.
2) refresh page (probably won't help, but on the off-chance that it has your files confused)
3) post your exact and full code, in such a way that copying it and running it produces that error message (so that i get something to reproduce the problem with)

edit: actually I am able to reproduce with what you posted, brb with an edit
edit2:
What you gave me:

demo_array=[5,10,15,20,25,30]
print demo_array[2]

Triggers a different error from the one you described.
This new error is bothered by that you have changed the values, meaning that the third value is now a different one than what it looks for.


#6

Changed the values in the array, still brings the error


#7

But did you change them back to the same thing? Just changing them won't do, has to be the same, at least the third value does.

Suggestion: copy your code, click the Reset button, then paste your code back in below and decide what to keep.


#8

Clicked the reset button and got the initial values. Thanks for the help


#9

https://www.codecademy.com/en/courses/deploy-a-website/lessons/create-static-site/exercises/generate-site?action=resume

What could be the error of 1s command


#10

No idea what you mean.