@anonymous/OblongLikableHaddock
Python

No description

repl talk
Files
  • main.py
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
class Queue :
    def __init__(self):
        self.items = []

    def insert(self, item):
        self.items.insert(0, item)

    def remove(self):
        if self.items == []:
            raise BaseException, "List is empty!"
        return self.items.pop()

    def is_empty(self):
        return (self.items == [])
        
class LinkedList :
    def __init__(self):
        self.items = []

    def addFirst(self, item):
        self.items.insert(0, item)
        
    def append(self, item):
        self.items.append(item)
        
    def removeFront(self):
        if self.items == []:
            raise BaseException, "List is empty!"
        return self.items.pop(0)
        
    def removeEnd(self):
        if self.items == []:
            raise BaseException, "List is empty!"
        return self.items.pop()
        
    def is_empty(self):
        return (self.items == [])
Python 2.7.10 (default, Jul 14 2015, 19:46:27) [GCC 4.8.2] on linux