Implement a Stack class and an EmptyStackError exception class. The Stack class should use a list to store its items, and should provide pop() to return and remove the item at the top of the stack (the right-most item), top () to return the item at the top of the stack, and push() to push a new item onto the stack. Also provide special methods so that len() and str() will work sensibly. Make sure that pop() and top() raise EmptyStackError if the stack is empty when they are called. The methods can be written using very few lines of code. Make sure you use the doctest module and write unit tests for all the methods.
Already registered? Login
Not Account? Sign up
Enter your email address to reset your password
Back to Login? Click here