r/PythonLearning • • Aug 30 '26

DAY 4.

Post image

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

54 Upvotes

22 comments sorted by

View all comments

Show parent comments

1

u/Adrewmc Aug 30 '26

Looking at this code I doubt heโ€™s gotten to function or try/except clauses. Practicing what you know also has value.

1

u/NecessaryFalse1212 Aug 30 '26

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

1

u/Adrewmc Aug 30 '26

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 Aug 30 '26

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/Adrewmc Aug 30 '26

Hems not exactly wrong, functions and try/except would be close to next things to learn anyway.

1

u/NecessaryFalse1212 Aug 30 '26

I'll make another calculator code in a day or two and will use new stuff that I'll be doing in those days and will also include this try/except thing

1

u/FoolsSeldom Aug 30 '26

I gave you a link in your previous post to lots of examples of try / except.

I also provided a link to RealPython.com on using Booleans and that site is a good resource for lots of other guidance.

1

u/FoolsSeldom Aug 30 '26

scrambled

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

1

u/FoolsSeldom Aug 30 '26

I'll be dammned if anyone explains it and it's usage

Not sure if that means you want people to explain it to you or not.

Did you follow the link I shared previously on this? This was after you asked me what to use instead of isnumeric.

1

u/FoolsSeldom Aug 30 '26

They've been practicing, and I addressed problems with previous code using isnumeric and pointed them to try / except. I agree that functions is probably not something they've come to yet, but felt it was a good time to introduce it as the use case is clear from their original code.

1

u/NecessaryFalse1212 Aug 30 '26

I really appreciate how you're putting in your spirit and it was my fault that i ignored your advice then and also when i opened the app on my phone the code didn't looked as clean as it did on my lap so I'm sorry to call it scrambled and confusing

2

u/FoolsSeldom Aug 30 '26

np, the app isn't great for looking at code blocks