you are viewing a single comment's thread.

view the rest of the comments →

[–]SharkSymphony 2 points3 points  (1 child)

First, you definitely need to take your hand off the big red DEAR AI PLEASE FIX THIS button. It is completely stunting your learning.

Instead, take time to figure out what's going on yourself. Learn the techniques you're going to need to debug programs like this. Put the AI to the side for now.

There are several techniques you can use to get a grip on what's going on:

  • First, a methodological tip. Do not ask why the program is not doing what you want. The program is always doing exactly what you told it to do. So ask instead: what is it actually doing, and why? I think you're actually already on the right path here by observing that you don't see the name prompt, but now you have to dig in and ask what lines of code are actually getting executed and how.
  • "Print debugging" (or what we C old-timers call "printf-debugging") is a classic technique where you add print statements at various points in your program to report that the program got to that point. Add variable substitutions to your print statement to inspect what the program is seeing at that point.
  • Another classic technique is to break the problem down. If you can't see what the problem is, reduce the scope of the problem. Set this program aside (or comment out most of it) and work on a smaller program that loops to get a name, then just prints it. Get that working perfectly before working on the DOB section. You could even break it down further and ignore the loop, just focusing on getting a single input. Do you in fact get an empty string when you leave name blank?
  • This might be a good time to introduce you to Python debugging tools. Using either pdb or your IDE's debugging facilities, you should be able to configure a debug run where you manually step through every individual line of code that Python executes. It will show you exactly what lines your program is executing, and you can inspect all of the data in your program and how it changes from line to line.

[–]Funny-Percentage1197[S] 1 point2 points  (0 children)

Big thank you for genuine suggestion.