from stack import Stack

class BrowserHistory():

    def __init__(self):
        self.history = Stack()
        self.current_page = None

    def add_page(self, url):
        self.history.push(self.current_page) # www.wp.pl www.o2.pl www.giganci.pl
        self.current_page = url

    def go_back(self):
        prev_url = self.history.pop()
        if prev_url is not None:
            self.current_page = prev_url

    def print_history(self):
        print(f'Current page: ' + self.current_page)
        print(f'History: ')
        for page in reversed(self.history.list):
            print(page)

browser = BrowserHistory()
browser.add_page('www.wp.pl')
browser.add_page('www.o2.pl')
browser.add_page('www.giganci.pl')
browser.print_history()
browser.go_back()
browser.print_history()
browser.go_back()
browser.print_history()