Question: In python add a method to this code provided that reverses the contents of the stack. Thanks! class Stack: def __init__(self): #creating an empty list

In python add a method to this code provided that reverses the contents of the stack. Thanks!

class Stack: def __init__(self): #creating an empty list self.list=[] def push(self,item): #append to list self.list.append(item) def pop(self): #dont mention what you want to pop return self.list.pop() def peek(self): return self.list[len(self.list)-1] def size(size): #return len of list return len(self.list) def is__empty(self): if len(self.list)==0: return True else: return False s1=Stack() s1.push(5) s1.push(6) s1.push(7) In python add a method to this code provided that reverses the 

class Stack: def init_(self): list #creating an empty self. list=[] def push(self,item): #append to list self.list.append (item) def pop (self): #dont mention what you want to pop return self.list.pop() return self.list[len(self.list)-1] #return len of list return len(self.list) if len(self.list)-0: else: def peek(self): def size(self): def is_empty (self): return True return False s1-Stack() s1.push(5) s1.push(6) s1.push(7) print (s1.peek)) print (s1.size))

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!