CodeField

Repeat it

Task 6 of 7

Write

Read whole numbers, one per line, until a line holds 0. Then print their total and how many numbers there were, not counting the 0, on one line with a space between them. Use a while loop.

  • Example: 5 and 7 and 0 gives 12 2
  • Example: 0 gives 0 0

Your program, Python

Tab indents. To leave, press Escape, then Tab.

Compare it with a model answer now, or come back on a device that can run Python.

Python for this device

Writing tasks run your program on this device. That needs Python: 5.5 MB, once. About 2 minutes on 3G, about 8 on a slow connection. It stays on this device. Remove it in Settings at any time.

You can do the other tasks while it downloads.