❓ What does [ ::-1 ] do?
❗️ Answer: [::-1] is used to reverse the order of an array or sequence.
🔍 For example:
import array as arr
My_Array=arr.array('i',[1,2,3,4,5])
My_Array[::-1]
Output: array('i', [5, 4, 3, 2, 1])
🌟 [::-1] reprints a reverse copy of an ordered data structure such as an array or list. The original array or list remains unchanged.
❗️ Answer: [::-1] is used to reverse the order of an array or sequence.
🔍 For example:
import array as arr
My_Array=arr.array('i',[1,2,3,4,5])
My_Array[::-1]
Output: array('i', [5, 4, 3, 2, 1])
🌟 [::-1] reprints a reverse copy of an ordered data structure such as an array or list. The original array or list remains unchanged.