- 1

What will be filled in the blank to show first two elements of the list?

list=["a", "b", " c", "d"]: a= list [0 __]:

7th Mar 2017, 6:56 AM
Vaidehi Singh
Vaidehi Singh - avatar
8 Respuestas
+ 7
Fill in the blanks to take the first two elements of the list: list = ["a", "b", "c", "d"] a = list[0 : 2 ]
6th Oct 2020, 12:42 PM
Shravani Jogu
Shravani Jogu - avatar
+ 5
Yes we can use list[:2] here it will work but in the question its required to write the starting and ending values, so we bend our ways. It will still work though.
8th Sep 2019, 10:52 PM
OUSSAMA ROMDHANI
OUSSAMA ROMDHANI - avatar
+ 3
a =list[0:2] is correct answer
2nd Mar 2021, 4:17 PM
v manojbabu
v manojbabu - avatar
+ 1
list[x:y:z] traverses the list, beginning with the x'th element, finishing with the y'th (not included), and with steps of z. EDIT: the ":z" part is optional. If omitted, it's understood to be 1.
7th Mar 2017, 7:05 AM
Álvaro
0
need more explanation. kindly explain it further please.
7th Mar 2017, 7:28 AM
Vaidehi Singh
Vaidehi Singh - avatar
0
I believe you want to slice your list. So, to show the first 2 elements, I'd guess a = list[0:3]
7th Mar 2017, 1:05 PM
LayB
LayB - avatar
0
:2
29th Jul 2019, 3:18 PM
DARCIO KASHWANTALE NETO
0
:2
11th Jan 2020, 6:20 AM
Babeetha Muruganantham
Babeetha Muruganantham - avatar