I am trying to use python-idiom to reverse a list of lists so that, for example,
a = [[1, 2], ['apple', 'orange']]
b = [['orange', 'apple'], [2, 1]]
My code for this at present is:
import copy a = [[1, 2], ["apple", "orange"]] if type(a) is list: b = copy.deepcopy(a) for item in b: (map(item.reverse(), item)) b = map(b.reverse(), b) print a, b
Is there a simpler, more elegant, pythonesque way to do this using map(), filter(), reduce() and friends and possibly recursion?