How do I make a back button for a browser | Sololearn: Learn to code for FREE!

0

How do I make a back button for a browser

I need to make a back button for a browser use stack. https://www.sololearn.com/learning/1159 class Browser: def __init__(self): self.links = [] def is_empty(self): return self.links == [] def push(self, link): self.links.insert(0, link) x = Browser() x.push('about:blank') x.push('www.sololearn.com') x.push('www.sololearn.com/courses/') x.push('www.sololearn.com/courses/python/') while not x.is_empty(): print(x.pop())

7/25/2021 2:12:04 AM

Tingxi Tan

2 Answers

New Answer

+1

Add following member function def pop(self): rv = self.lists[-1] self.lists = self.lists[:-1] return rv it will helpful to complete code DHANANJAY PATEL

+1

Another way is def pop(self): return self.lists.pop() DHANANJAY PATEL