Objective
Create a Python program that implements a singly linked list with a Node class (value and next) and a LinkedList class (head), and operates it with commands.
Instructions
- Read an integer
nand thenncommands. Values are integers. Do not use Python lists to store the data: link nodes. append Xandprepend Xadd a node at the end or at the beginning (showing nothing).remove X: removes the first occurrence of X and showsRemoved: X, orNot found: Xif it is not there.reverse: reverses the list by changing the links (showing nothing).show: shows the values separated by->, for example1 -> 2 -> 3, orEmpty listif it is empty.
8
append 2
append 3
prepend 1
show
remove 2
reverse
show
remove 9
1 -> 2 -> 3
Removed: 2
3 -> 1
Not found: 9
Open the editor in full screen: the statement on the left and your code, the output and the tests on the right.
Start exercise