Answered step by step
Verified Expert Solution
Question
1 Approved Answer
May I please know how to program this question in python step by step? Thank you You are to write a function called arrange. Your
May I please know how to program this question in python step by step? Thank you
You are to write a function called arrange. Your function will reorder a given list, where even indexed elements are arranged by descending order (based on index order) from 0 to n/2 of the list and odd indexed elements arranged in ascending order from (n/2) + 1 to n 1. Your function does not need to return the list but to change the existing list passed as an argument. Please remember, if you reassign the argument variable, you no longer have access to the original list contents. n refers to the number of elements in the list Your function will modify and rearrange the list passed to the function and the order will be checked How the list is reordered: Unchanged list Index: 0 1 2 3 45 6 Data: [3, 5, 2, 8, 7, 9, e] Rearranged list Index: 6 4 2 0, 1, 3,5 Data: [e, 7, 2, 3, 5, 8, 9] 6, 4, 2, e: Descending order from to n/2 1, 3, 5: Ascending order from n/2+ 1 to n-1 Example 1 Input:[1, 2, 3, 4, 5] Rearranged: [5, 3, 1, 2, 4]Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started