1.

Suppose list1 is [4, 2, 2, 4, 5, 2, 1, 0], Which of the following is correct syntax for slicing operation?(a) print(list1[0])(b) print(list1[:2])(c) print(list1[:-2])(d) all of the mentionedThis question was posed to me in an interview.The above asked question is from Lists topic in portion Lists & List Comprehension of Python

Answer»

Right answer is (d) all of the mentioned

The EXPLANATION: SLICING is ALLOWED in lists just as in the CASE of strings.



Discussion

No Comment Found

Related InterviewSolutions