Information about cookies on this page

Our website uses cookies to ensure the functionality of the website, to collect and analyze information about the performance and usage of the website. Privacy Policy

  • Courses
    • Discord
    • Twitter
    • Linkedin
    • Facebook
    • Instagram
  • Pricing
  • English
  • Čeština
  • Deutsch
  • Русский
Sign inStart free
  • Courses
  • Pricing

Community

Sign in
  
  • Courses
    • Discord
    • Twitter
    • Linkedin
    • Facebook
    • Instagram
  • Pricing
  • English
  • Čeština
  • Deutsch
  • Русский
Sign inStart free
  • Courses
  • Pricing

Community

Sign in

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. 1

    Add to the message the form you need: only the function, with a comment on each line. Then send it.

  2. 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.

Back

4/6

  1. 1. What Goes In, What Comes Out
  2. 2. Examples Settle What Words Don't
  3. 3. What You Know, Where It Runs
  4. 4. The Form You Need
  5. 5. Quiz: Which Request
  6. 6. Summary
Next

Start programming for free

By signing up, you agree to the Terms of Service and Privacy Policy.

Or sign up with: