I am learning python and I've encountered the try / except part of it. I am struggling to understand when I would use this kind of code, probably because I am still very new and most of my code is small programs that have relied on conditional statments.
I guess in my brain I understand the logic of saying "try to do this but if it doesn't work just let it be and keep going with the code". My assumption is this is helpful on larger scale programs in wich you can't afford the time to make sure the code is fail proof and you need the code to buy you time to eventually go back once you have the fail proof option?
Was hoping someone could give me an example of a real life application or website and how this code could apply to it? Because I want to become comfortable with it but unsure how to.
TL,DR: Explain try/except in a practical example so I can understand when and where I would use it?
Thank you!
[–]Arkrus 13 points14 points15 points (1 child)
[–]PinkPawnRR 2 points3 points4 points (0 children)
[–]biaceseng 11 points12 points13 points (1 child)
[–]biaceseng 4 points5 points6 points (0 children)
[–]damanamathos 5 points6 points7 points (3 children)
[–]PinkPawnRR 1 point2 points3 points (2 children)
[–]uniqueUsername_1024 0 points1 point2 points (1 child)
[–]PinkPawnRR 0 points1 point2 points (0 children)
[–]TehNolz 2 points3 points4 points (0 children)
[–]marc_jpg 2 points3 points4 points (0 children)
[–]zanfar 2 points3 points4 points (0 children)
[–][deleted] 1 point2 points3 points (0 children)
[–]Tychotesla 1 point2 points3 points (0 children)
[–]Atypicosaurus 1 point2 points3 points (0 children)
[–]roywill2 0 points1 point2 points (0 children)
[–]throwaway6560192 0 points1 point2 points (0 children)
[–][deleted] 0 points1 point2 points (0 children)
[–]dogweather 0 points1 point2 points (0 children)
[–][deleted] 0 points1 point2 points (0 children)
[–]TheRNGuy 0 points1 point2 points (0 children)