Predict the output of the following code snippet?
Input: 12,3,4,5,7,12,8,23,12
l=eval(input("Enter the list:"))
n=len(l)
t=l[1:n-1]
print(t)
Answers
Answered by
0
Answer:
The output should be:
[3, 4, 5, 7, 12, 8, 23]
Explanation:
n=len(l) which is 9.
Now,
t returns the sliced list ranging from index 1 to index n-1=9-1=8 which begins as 3 and ends on 23 (one index before the last index i.e index 7 when last limit is 8).
Similar questions
Physics,
2 months ago
Math,
2 months ago
Political Science,
2 months ago
English,
5 months ago
Political Science,
11 months ago