Why must L[0] be wrapped as [L[0]] before concatenating it after my_rev(L[1:]) — and what does that say about the type every return must hand back?
Short drills on what this video just taught. Write the code, run the checks, and reveal the answer only if you are stuck.
Someone has already reversed the remainder of a list for you. You are handed these two names:
items = [3, 8, 12, 5, 9] rest_reversed = [9, 5, 12, 8]
Using both of them, finish the job: assign to combined the full reversal of items, built by putting the element that was peeled off items where it belongs relative to rest_reversed.
Concatenation joins a list to a list. (Hint: items[0] peels the first element, + concatenates, and square brackets build a list.)
Concatenating the first element after the reversed remainder
Write my_rev as return my_rev(L[1:]) + [L[0]] with len(L) == 1 returning L, and run it on [1, 2, 'abc'] for ['abc', 2, 1].
The square brackets around [L[0]]
State that every my_rev return hands back a list, and record that L[0] is the bare integer 10 for [10, 20, 30, 40], so the concatenation takes [L[0]].
Reversal only at the top level
Run my_rev on ['abc', ['d'], ['e', ['f', 'g']]] for [['e', ['f', 'g']], ['d'], 'abc'], and write the deep result [[['g', 'f'], 'e'], ['d'], 'abc'] beside it.