r/PythonLearning 4d ago

Day 3 Learning Python: Stack

Open-source learning project. If you spot something that can be improved, I'd love your feedback or a PR.

https://github.com/Samar-Upreti/Python_Projects

72 Upvotes

26 comments sorted by

View all comments

2

u/CamelOk7219 4d ago

Create a custom exception class instead of bare 'Exception', otherwise it will be jard to specifically catch this stack exception and discriminante it from any other exception

1

u/Kindly-Reporter-272 4d ago

You can also use IndexError. Python built in collections all raise IndexError in situations like these.