Give the output of following : a=[2,7,9,13,28] print(a[2:]+a[:2])
Answers
Answered by
2
[9, 13, 28, 2, 7]
a[2:] slices items starting from index 2 to till end of list.
a[:2] slices items from the start of list and stops at index 2
print(a[2:] + a[:2]) concatenates the result of both the slices into a new list and prints the result
Similar questions