← Back to challenges

Reverse a Linked List

PythonHarddata_structuresloops

Instructions

Given a linked list class, implement a method called reverse() that reverses the linked list.

Examples

Input: 10 -> 20 -> 30 -> 40 -> None

Output: 40 -> 30 -> 20 -> 10 -> None

Notes

Just implement the reverse() function and DO NOT modify any other code in the Code tab, which has nothing but the starter code.

python3
Loading editor…
⌘ ↵ to run
Walks through the solution with reasoning and edge cases.