Reverse a List With Step Slicing

Easy ⏱ 8 min 83% acceptance ★★★★★ 4.7
Write reverse_list(items) that returns a new reversed list using slice notation ([::-1]), without mutating the original list or using .reverse().

Examples

Example 1
Input
items = [1, 2, 3, 4]
Output
[4, 3, 2, 1]
Explanation

A step of -1 walks the list backwards.

Constraints

  • 0 <= len(items) <= 10^4
  • The original list must remain unchanged.

Topics

ListsSlicing

Companies

MicrosoftAccenture

Hints

Hint 1

items[::-1] creates a reversed copy.

Loading the Python runtime… Run executes your code and shows printed output; Submit checks your function against this problem's examples.