Python Program to Reverse Elements of an Array

    
        def reverse_array(arr):
            start, end = 0, len(arr) - 1

            while start < end:
                # Swap elements at start and end indices
                arr[start], arr[end] = arr[end], arr[start]

                # Move indices towards the center
                start += 1
                end -= 1

        # Initialize an empty array
        array_of_elements = []

        # Get the number of elements you want in the array from the user
        elements = int(input("Enter the number of elements you want in the array: "))

        # Loop to take user input and add numbers to the array
        for i in range(elements):
            # Get the element from the user
            user_input = int(input(f"Enter element {i + 1}: "))

            # Add the number to the array
            array_of_elements.append(user_input)

        print("Original Array:", array_of_elements)

        reverse_array(array_of_elements)

        print("Reversed Array:", array_of_elements)

    
Output:
    
        Enter the number of elements you want in the array: 5
        Enter element 1: 44
        Enter element 2: 23
        Enter element 3: 54
        Enter element 4: 16
        Enter element 5: 2
        Original Array: [44, 23, 54, 16, 2]
        Reversed Array: [2, 16, 54, 23, 44]