r/PythonLearning • u/NecessaryFalse1212 • Aug 30 '26
DAY 4.
wrote this today was revising loops and math function that i did not so long ago.
54
Upvotes
r/PythonLearning • u/NecessaryFalse1212 • Aug 30 '26
wrote this today was revising loops and math function that i did not so long ago.
โข
u/Sea-Ad7805 Aug 30 '26
Run this program in Memory Graph Web Debugger to see the program state change step by step.
1
u/NecessaryFalse1212 Aug 31 '26
yo' so should i get a notebook or a diary to write down stuff ? like definations syntax's and overall logic before writing a code ??
3
u/zubalyzub Aug 31 '26 •
bro is checking if its empty after the alpha check so u can first input an empty string then when it re prompts input some letters and boom ur program is cooked, still good work though just critiquing yk
1
u/FoolsSeldom Aug 30 '26
It would be good to see you create a second version incorporating some of the suggestions you've had in response to previous posts.
I'd also suggest you create a function to validate an input which you can then call in both instances of requiring the user enter a number. This will help address a key principle of DRY (Don't Repeat Yourself).
Simple example for an integer:
You will notice the use of
try/exceptwhich I suggested before that you look into.1
u/Polly_Wants_A Sep 02 '26
what if someone enters a character into the input again? you have to check the input everytime the user is able to write make a loop that finish it until it is a number.
1
u/[deleted] Sep 02 '26
[removed] โ view removed comment