0

Someone can explain me this code? i solved but i dont understand his fuction

class Browser: def __init__(self): self.links = [] def is_empty(self): return self.links == [] def push(self, link): self.links.insert(0, link) def pop(self): return self.links.pop(0) x = Browser() x.push('about:blank') x.push('www.sololearn.com') x.push('www.sololearn.com/courses/') x.push('www.sololearn.com/courses/JUMP_LINK__&&__python__&&__JUMP_LINK/') while not x.is_empty(): print(x.pop())

23rd Aug 2022, 7:21 PM
Josué Varela
Josué Varela - avatar
3 Answers
+ 1
An instance of the Browser is created (x), links are added. In the while loop, links are removed until it is empty.
23rd Aug 2022, 7:35 PM
Lisa
Lisa - avatar
0
Lisa I thought that if there was an empty link, the loop would delete it and not that it was all deleted until it was empty
23rd Aug 2022, 11:22 PM
Josué Varela
Josué Varela - avatar
0
What is an empty link? Try to run this code and see what is being removed.
24th Aug 2022, 6:50 AM
Lisa
Lisa - avatar