Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

In python write another method in this code that compares two stacks to see if they are equal or not. Here is the code that

In python write another method in this code that compares two stacks to see if they are equal or not. Here is the code that needs to be altered.

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(self): #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) print (s1.peek()) print(s1.size())

image text in transcribed

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

The Ages Of The Investor A Critical Look At Life Cycle Investing

Authors: William J Bernstein

1st Edition

1478227133, 978-1478227137

Students also viewed these Databases questions

Question

How would your friends describe you?

Answered: 1 week ago