Given List Return New List Twists Order Items Original Twisted List Swaps Every Non Overla Q37115281

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


saved main pyO 1 def twistlist (inputlist): https://GrumpyNewGnuassembler.a Python 3.6.1 (default, Dec 2015 [GCC 4.8.2] on li

def twistList(inputList): for i in range(0, len(inputList), 2): # swap items at index i and

OR
OR

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.