0

Not understanding slicing, I'm stuck

I am in a AI generated practice. The instructions are to complete the code to output watermelon. Here is the iam try to pull from. items = ["water", "bread", "orange ", "melon"] Here is the code I am trying to complete, print (items [ ] items [ ]) Not sure what to put in first set of square brackets. and then what syntax to put between the square bracket and items, and what to put in the last set of square brackets

5th Sep 2023, 8:48 PM
James StClair
James StClair - avatar
2 Réponses
+ 6
Remember list[] starts from index 0. The + symbol is used to concatenate the two strings. So what would the index for water and melon be? Try this in your editor. items = ["water", "bread", "orange", "melon"] print (items[ # ] + items[ # ]) In place of # put in the correct index number to get the #output: "watermelon"  
5th Sep 2023, 9:23 PM
Chris Coder
Chris Coder - avatar
0
Thanks Chris, for assist. I'm no longer stuck. Thanks again. James
6th Sep 2023, 2:38 PM
James StClair
James StClair - avatar