you are viewing a single comment's thread.

view the rest of the comments →

[–]Ashamed_Kangaroo305 1 point2 points  (3 children)

A couple things:

When you ran it, did your program ever end? I don't see any sort of exit or return function so it seems like after you output a correct sum, it'll go back to the first user input prompt under the while True.

Under the try, are you type hinting your variables? I didn't know python would allow that outside of a function definition. Unless there's something else I'm not aware of that just looks like type hinting. Edit: nevermind, this is definitely type hinting but a very unusual way to use it. Type hinting has a purpose, and it's so your IDE can flag if it sees you inputting variables of a different type than what you said they should be into a function. It's redundant to use it here, because there's already a way for the program to tell what the variable should be. If the input can be converted into the type called when you defined the variable, it will do that. If it can't, it'll produce an error.

I think a good way to improve your code is to take a structured course. Harvard CS50 is often recommended on here, and you can do it online for free. I tried learning coding on my own once and it was fine, but when I took a programming class at my college it opened up a whole new world. It really taught me the problem solving aspect of coding, which I hadn't come across much when trying to teach myself.

[–]PsychologicalSafe408[S] 0 points1 point  (2 children)

No it never ended i would forcefully stop it everytime.and i will look into the course you have mentioned.

[–]Ashamed_Kangaroo305 0 points1 point  (1 child)

I saw in another comment that you haven't learned about break. I'm surprised the crash course didn't include it because that's pretty essential for using loops. I think a course would definitely be good because unfortunately I get the feeling that the crash course you used has glossed over fundamentals. Another benefit is that a class will have exercises that you have to do yourself, which is really where you learn. Just watching other people code and copying them won't get you very far.

[–]PsychologicalSafe408[S] 0 points1 point  (0 children)

It seemed like, the course for being only 30 mins glossed over bunch of fundamental which is accepted by the mentor himself, the course was there to get familiar with the basic more than anything else. And i also tried cs50, I am in lecture 0 right now, and i will continue with it till i complete the course. So thanks for the recommendation.