Ask for a script and you get one written the way a competent developer would write it: compact, idiomatic, using features that assume familiarity. That is the right answer for somebody who already codes and the wrong one for somebody learning.
What makes generated code hard to read?
Density. Experienced code does several things per line, uses shorthand constructions and relies on conventions you have not met. None of it is wrong, and all of it is opaque if you are two weeks in.
What should you ask for?
Write this in the simplest way possible, even if it is longer or less efficient. One operation per line. No comprehensions, no lambda functions, no chained operations and no clever shortcuts. Use descriptive variable names. Add a comment above each line explaining what it does and why.
Naming the specific constructions to avoid works better than asking for beginner-friendly code, which is interpreted loosely.
Why ask for it to be less efficient?
Because efficiency and readability trade against each other, and at this stage readability is the entire point. A loop that takes three lines and can be followed beats a one-line version that cannot, and the difference in speed is irrelevant for anything you will write this year.
What else improves comprehension?
- Descriptive names. A variable called customer_count rather than n.
- Explicit steps. Storing intermediate results rather than nesting operations.
- Standard library only. Fewer unfamiliar imports to decode.
- Comments explaining why. Rather than restating what the line does.
How do you check you understood it?
Explain it back and ask what you got wrong, with an instruction not to be encouraging. This is the single most useful thing an assistant does for a learner, and almost nobody uses it.
Here is my understanding of what this script does, line by line. Tell me specifically what I have got wrong or imprecise. Do not tell me what I got right.
What if the explanation is still too advanced?
Say what you already know rather than asking for something simpler. Simpler is relative to an audience the model has to guess at; naming your actual starting point is precise and produces an explanation that begins in the right place.
Should you accept code with unfamiliar parts?
Only after asking about them. An unexplained line in a working script is a thing you will copy into the next script and the one after that, and by the tenth script a third of your code is material you cannot reason about.
Should you ask for the whole thing at once?
Not while learning. A script requested in one go arrives complete, and reading forty lines of unfamiliar code is considerably harder than following it being built.
Asking for it in stages, with each part explained before the next, produces the same script and a far better understanding of it. It also lets you catch a misunderstanding at line ten rather than discovering at line forty that the whole approach was based on something you did not mean.
What is the underlying rule?
Never run code you cannot explain. It sounds slow and it is the difference between learning to program with AI and accumulating scripts. The scripts are worth very little; the ability to write the next one without help is the thing you are actually after.