- 1
What will be filled in the blank to show first two elements of the list?
list=["a", "b", " c", "d"]: a= list [0 __]:
8 Réponses
+ 7
Fill in the blanks to take the first two elements of the list:
list = ["a", "b", "c", "d"]
a = list[0 : 2 ]
+ 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.
+ 3
a =list[0:2]
is correct answer
+ 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.
0
need more explanation. kindly explain it further please.
0
I believe you want to slice your list. So, to show the first 2 elements, I'd guess
a = list[0:3]
0
:2
0
:2