Is the answer to this question valid? as >>> a [3] is supposed to be = 4 | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 6

Is the answer to this question valid? as >>> a [3] is supposed to be = 4

Please note that the sign ( « ) isn't originally in the code, it is, to specify my interest. QUESTION: Fill in the gap to print Hello world ! a = [ 1, 2, 3, 4] a [ ] « = 2 If 4 in a : Print( "Hello world !") else: Print("Goodbye world") ANSWER: a = [ 1, 2, 3, 4] a [ 3 ] « = 2 If 4 in a : Print( "Hello world !") else: Print("Goodbye world") I thought that if we wanted to know the position of [3] in the list, we should use a.index(3) instead . Pls anyone? Explain this. Maybe i'm wrong on my part, i need to understand .

21st Jul 2020, 12:47 AM
𝕱𝖗𝖆𝖓𝖐𝖞
𝕱𝖗𝖆𝖓𝖐𝖞 - avatar
3 Answers
+ 6
Ok thanks a lot~ swim ~ This isn't the only question like this, I've been losing challenges because of this, and i prefer understanding the question to learning it the way it is.
21st Jul 2020, 1:37 AM
𝕱𝖗𝖆𝖓𝖐𝖞
𝕱𝖗𝖆𝖓𝖐𝖞 - avatar
+ 4
That's exactly what I'm complaining about. The output should be "Hello world !" , but 4 in a is replaced as 2 because a [3] = 2. So it will print "Goodbye world" instead, this question should be removed from the py quiz or corrected, such that the question will state: Fill in the gap to print "Goodbye world" instead of "Hello world"
21st Jul 2020, 1:20 AM
𝕱𝖗𝖆𝖓𝖐𝖞
𝕱𝖗𝖆𝖓𝖐𝖞 - avatar
+ 4
I didn't I was just checking through correct answers after a challenge, and i saw 3 in empty space as the answer left for me i'll put 1 in the empty space
21st Jul 2020, 1:27 AM
𝕱𝖗𝖆𝖓𝖐𝖞
𝕱𝖗𝖆𝖓𝖐𝖞 - avatar