- 2

stuck in python

What does this code output? letters = ['x', 'y', 'z'] letters.insert(1, 'w') print(letters[2])

24th Jun 2017, 6:38 PM
Jaap
6 ответов
+ 6
Y
28th Mar 2019, 2:04 AM
Shradha Dholariya
Shradha Dholariya - avatar
+ 4
When you insert 'w' to the index 1, the list becomes: x, w, y, z. So y is at index of 2, so the output is y. Remember the index starts at 0.
24th Jun 2017, 6:46 PM
Rrestoring faith
Rrestoring faith - avatar
+ 3
Oups. Typo. Thanks!
24th Jun 2017, 7:36 PM
Rrestoring faith
Rrestoring faith - avatar
+ 2
ok
4th Mar 2019, 9:48 AM
MAX EARNSHGAAW
MAX EARNSHGAAW - avatar
+ 2
the answer is Y
5th Apr 2020, 1:03 PM
sohail ayoub
sohail ayoub  - avatar
+ 2
y
1st Oct 2020, 3:20 PM
Isaiah Hudson
Isaiah Hudson - avatar