The Form You Need
An answer has more than code in it. Asked for a function, the assistant usually adds an explanation, an example of calling it in a block of its own, and sometimes your whole program again with the function in it. One answer to the message in the chat box had the function, and then:
How it works:
1. count = 0 starts a counter at zero.
2. for minutes in walks: goes through each walk in the list, one at a time. On each pass, minutes holds that walk's length.It went on through every line and ended with an example that calls the function on walks of its own. That's good to read once. But in your program, the code is all that's left of the answer, and an example call you paste along prints lines of its own. When you know what you'll do with the code, say what form you need:
- only the function, to paste into a program that has the rest;
- a comment on each line, to read it again later in the editor, without the chat;
- or whatever else you need: the whole program, a shorter answer, only the line to change.
Mia also wants to know how many of her walks were an hour or longer. The message in the chat box already says what goes in, what comes out and what you know. The function needs nothing else from your program, so there's nothing to attach.
Instructions
- 1
Add to the message the form you need: only the function, with a comment on each line. Then send it.
- 2
Paste the function in place of the comment and run the program. Keep the line with the walks: the program prints
Long walks: 2.