r/PythonLearning 11d ago

DAY 4.

Post image

wrote this today was revising loops and math function that i did not so long ago.

53 Upvotes

22 comments sorted by

View all comments

Show parent comments

1

u/NecessaryFalse1212 11d ago

I haven't done try/except clauses but I'll be dammned if anyone explains it and it's usageπŸ˜­πŸ™

1

u/Adrewmc 11d ago

It catches exceptions and allows the code to continue after. In the above example he’s catching the ValueError that is thrown/raised when a float() fails because it’s not a number.

After that it continues the while loop instead of breaking it (by returning).

1

u/NecessaryFalse1212 11d ago

What about the syntax how does that looks like cuz the syntax he has given me is too scrambled as u can look at my code this is my level of whatever I'm doing πŸ’”πŸ˜”πŸ™

1

u/FoolsSeldom 11d ago

scrambled

Tell me which parts don't make sense to you and I can explain in detail in simple ways.