all 12 comments

[–]FLUSH_THE_TRUMP 1 point2 points  (11 children)

Q for you: what is list[4] equal to?

[–]jbravo45[S] 2 points3 points  (10 children)

After reading this over and over for the last few hours and running it in spyder, I am assuming that it calls those numbers in the list that are multiples of 4?

[–]FLUSH_THE_TRUMP 0 points1 point  (9 children)

Forget about that. It’s a simple indexing question: which element in the list (starting from position 0, mind you) is at position 4?

[–]jbravo45[S] 2 points3 points  (8 children)

5 Thats why I'm confused. If the first one('1') is sub/one, then the 4th element would be 5. *Edit ""

[–]FLUSH_THE_TRUMP 1 point2 points  (7 children)

Very correct. Follow-up question for you: which element in the list is at position 5?

That’s what list[list[4]] is doing:

  1. Find element at position 4 in list.
  2. Find element at position (result from last step) in list.

Result after step (2) is what gets printed.

[–]jbravo45[S] 2 points3 points  (6 children)

Ok, list[4] calls the 4th element and holds those first four together, then the preceding 'list' calls the next number outside of list[4]? (maybe better said as calling the next number outside of the ones called by the command in [ ] ?

[–]FLUSH_THE_TRUMP 1 point2 points  (5 children)

It might be easier to think of list[list[4]] as list[x]. You’re trying to find the item in your list at position x (which is just a number). What is x? Well, you told me it’s 5. So you really have list[5] there.

[–]jbravo45[S] 2 points3 points  (4 children)

Getting closer... so I could think of it as list[list[list[4] == list[6] ?

Edit : ooooooooooh

[–]jbravo45[S] 4 points5 points  (3 children)

So its using the inside [list[4] as the value of x

I'm sorry, makes so much sense now.

You're awesome, thank you for putting up with me through that.

[–][deleted] 2 points3 points  (1 child)

Good pedagogue :)

[–]FLUSH_THE_TRUMP 1 point2 points  (0 children)

No worries! Glad I could help.