Objective
Create a Python program that simulates the back and forward buttons of a browser using two stacks.
Instructions
- The browser starts on the page
home. Read an integernand thenncommands. visit PAGE: the current page goes onto the back stack, the forward stack is cleared andPage: PAGEis shown.back: moves to the previous page (the current one goes onto the forward stack) and showsPage: X. If there are no previous pages, showCannot go back.forward: the opposite operation; if there are no pages ahead, showCannot go forward.
6
visit a.com
visit b.com
back
back
back
forward
Page: a.com
Page: b.com
Page: a.com
Page: home
Cannot go back
Page: a.com
Open the editor in full screen: the statement on the left and your code, the output and the tests on the right.
Start exercise