Python Programming - Tricky Questions - Discussion

Discussion Forum : Tricky Questions - General Questions (Q.No. 29)
29.
What is the output of the following Python code?
x = [1, 2, 3, 4, 5]
result = x[-2:-1]
print(result)
[4]
[5]
[3, 4]
[4, 5]
Answer: Option
Explanation:
Slicing with indices -2:-1 returns a list containing the element at index -2 (counting from the end).
Discussion:
Be the first person to comment on this question !

Post your comments here:

Your comments will be displayed after verification.