Consider a series s1 = [1,4,6,8,10,12,14] , Which statement will produce output as [4,6,8,10]
Answers
Answered by
3
- Consider a list s1 = [1,4,6,8,10,12,14] , Which statement will produce output as [4,6,8,10].
Given list:
> s1 = [1, 4, 6, 8, 10, 12, 14]
Now, let us see the index of each elements in the list.
We have to display elements from index 1 to 4 using slicing. The códe goes like –
> s1[1 : 5]
Output:
> [4, 6, 8, 10]
Note: As last value is excluded, I have written 5 in place of 4.
Similar questions