Пример #1
0
    def test_reverse_whenListReversed_returnsAppropriateHeadAndTail(self):
        sl = SingleLinkedList()
        sl.add(1)
        sl.add(2)
        sl.add(3)

        sl.reverse()
        self.assertEqual(sl.head.value, 3)
        self.assertEqual(sl.tail.value, 1)
from LinkedList import SingleLinkedList

items = SingleLinkedList()
items.add_first(1)
items.add_last(2)
items.add_last(3)
items.add_last(4)
items.add_last(5)

items.print_out()
print(items.indexOf(2))

items.delete_first()
items.print_out()

items.delete_last()
items.print_out()

items.reverse()
items.print_out()

print(items.get_kth_from_end(2))