Apr-29-2019, 04:00 PM
For general purpose solution recursion seems suitable. However, in case of one level deep and only lists then oneliner will do ("for every element in reverse ordered list give me reverse ordered element if element is list otherwise element itself"):
>>> lst = ["WHAT","IS","THIS",["a nested list", 3, 8, 4.00]] >>> [list(reversed(el)) if isinstance(el, list) else el for el in reversed(lst)] [[4.0, 8, 3, 'a nested list'], 'THIS', 'IS', 'WHAT']
I'm not 'in'-sane. Indeed, I am so far 'out' of sane that you appear a tiny blip on the distant coast of sanity. Bucky Katt, Get Fuzzy
Da Bishop: There's a dead bishop on the landing. I don't know who keeps bringing them in here. ....but society is to blame.
Da Bishop: There's a dead bishop on the landing. I don't know who keeps bringing them in here. ....but society is to blame.