Python stack and queue classes, implemented using lists I have made a stack and queue implementation with OOP in Python (sorry for variable names) . It is made from scratch. I just watched a video how these two things work. I am still trying to improve in OOP so I would be thankful for every advice. Two things which bother me the most are using que and sta in the beginning and whether it is okay to just use already implemented functions in Python such as .pop() .

QUEUE

que = []

class Queue:
    def __init__(self,queue):
        self.queue = queue

    def push(self,item):
        print ("PUSH",item)

        if len(self.queue)!=0:
            self.queue.append(0)
            for i in range(len(self.queue)-1,0,-1): ## replacing elements 
                self.queue[i] = self.queue[i-1]
            self.queue[0] = item

        else:
            self.queue.append(item)

    def pop(self):
        print ("POP",self.queue[-1])

        if len(self.queue)!=0:
            self.queue.pop()
        else:
            raise ValueError('Cant pop from empty queue.')

    def __str__(self):
        return (str(self.queue))

## creating QUEUE  
que = Queue(que)
que.push(5)
print (que)
que.push(6)
print (que)
que.push(7)
print (que)
que.pop()
print (que)


STACK

class Stack:
    def __init__(self,stack):
        self.stack = stack

    def push(self,item):
        print ("PUSH",item)

        if len(self.stack)!=0:
            self.stack.append(0)
            for i in range(len(self.stack)-1,0,-1):
                self.stack[i] = self.stack[i-1]
            self.stack[0] = item

        else:
            self.stack.append(item)

    def pop(self):
        print ("POP",self.stack[0])

        if len(self.stack)!=0:
            self.stack.pop(0)
        else:
            raise ValueError('Cant pop from empty stack.')

    def __str__(self):
        return (str(self.stack))
## creating STACK
stac = Stack(sta)
stac.push(5)
print(stac)
stac.push(7)
print(stac)
stac.push(2)
print(stac)
stac.pop()
print(stac)
There are a few things to mention.

At first, it might be a good idea to initialize both Queue and Stack with empty lists by default:

def __init__(self, queue=None):
    self.queue = queue or []    # if queue is given, it overrides the default


Next, it doesn't make sense to write something like if len(self.queue)!=0 since it is equivalent to if self.queue (empty list is False when it's casted to bool). You can go even further and introduce the property called size using the built-in decorator:

@property
def size(self):
    return len(self.queue)


Now it can be accessed by self.size without a function call.