def test(self):
     """Testing linked list"""
     linked_list = LinkedList()
     linked_list.push_back(1)
     linked_list.push_back("foo")
     linked_list.push_back([3, 2, 1])
     self.assertFalse(linked_list.empty())
     self.assertEqual(linked_list.pop_back(), [3, 2, 1])
     self.assertEqual(linked_list.pop_back(), "foo")
     self.assertEqual(linked_list.pop_back(), 1)
     self.assertTrue(linked_list.empty())
 def test(self):
     """Testing linked list"""
     linked_list = LinkedList()
     linked_list.push_back(1)
     linked_list.push_back(2)
     linked_list.push_back(3)
     self.assertFalse(linked_list.empty())
     self.assertEqual(linked_list.pop_front(), 1)
     self.assertEqual(linked_list.pop_front(), 2)
     self.assertEqual(linked_list.pop_front(), 3)
     self.assertTrue(linked_list.empty())
 def test_delete_value_multi(self):
     """Testing linked list"""
     linked_list = LinkedList((6, 6, 8, 6))
     linked_list.delete_value(6)
     linked_list.delete_value(6)
     linked_list.delete_value(6)
     self.assertFalse(linked_list.empty())
 def test_delete_value_multi_instance(self):
     """Testing linked list"""
     linked_list = LinkedList((6, 6, 6))
     linked_list.delete_value(6)
     linked_list.delete_value(6)
     linked_list.delete_value(6)
     self.assertTrue(linked_list.empty())
 def test_delete_value(self):
     """Testing linked list"""
     linked_list = LinkedList((5, 3, 2, 8, 9))
     linked_list.delete_value(3)
     linked_list.delete_value(9)
     linked_list.delete_value(5)
     linked_list.delete_value(2)
     linked_list.delete_value(8)
     self.assertTrue(linked_list.empty())
def fact(number):
    '''"Pretend" to do recursion via a stack and iteration'''

    if number < 0:
        raise ValueError("Less than zero")
    if number in (0, 1):
        return 1

    stack = LinkedList()
    while number > 1:
        stack.push_front(number)
        number -= 1

    result = 1
    while not stack.empty():
        result *= stack.pop_front()

    return result