Returns - str Input - int ---------- - Moves backwards through history up to available steps - Updates navigation counters - Returns current page URL
(self, steps: int)
| 57 | self._back_count += 1 |
| 58 | |
| 59 | def back(self, steps: int) -> str: |
| 60 | """ |
| 61 | Returns - str |
| 62 | Input - int |
| 63 | ---------- |
| 64 | - Moves backwards through history up to available steps |
| 65 | - Updates navigation counters |
| 66 | - Returns current page URL |
| 67 | """ |
| 68 | # Only traverse available nodes |
| 69 | steps = min(steps, self._back_count) |
| 70 | while steps > 0: |
| 71 | self._curr = self._curr.prev |
| 72 | steps -= 1 |
| 73 | self._back_count -= 1 |
| 74 | self._forward_count += 1 |
| 75 | return self._curr.val |
| 76 | |
| 77 | def forward(self, steps: int) -> str: |
| 78 | """ |
no outgoing calls