Given a list, return a new list which ‘twists’ the order of theitems in the original. A ‘twisted’ list swaps every non-overlappingpair of items in the original list. (NOTE: for lists of odd length,the last element is not swapped with anything).
In Python.
Solution
def twistList(inputList): for i in range(0, len(inputList), 2): # swap items at index i and
OR
OR