Python Programming - Arrays - Discussion

Discussion Forum : Arrays - General Questions (Q.No. 2)
2.
What will be the output of the following code snippet?
numbers = [1, 2, 3, 4, 5]
sliced_numbers = numbers[1:4]
print(sliced_numbers)
[1, 2, 3, 4, 5]
[2, 3, 4]
[1, 2, 3]
[3, 4, 5]
Answer: Option
Explanation:
Slicing is used to extract a portion of a list. In this case, it extracts elements from index 1 to 3.
numbers = [1, 2, 3, 4, 5]
sliced_numbers = numbers[1:4]
print(sliced_numbers)
Discussion:
Be the first person to comment on this question !

Post your comments here:

Your comments will be displayed after verification.