What will the following code display?
numbers = [1, 2, 3, 4, 5]
my_list = numbers[:1]
print(my_list)
numbers = [1, 2, 3, 4, 5]
my_list = numbers[:1]
print(my_list)
output:
[1]
Explanation:
For example,if we declared as[;3],
then we'll get the elements till index 2,,,i.e.[1,2,3]
,if we declared as[;2],
then we'll get the elements till index 1,,,i.e.[1,2]