5. Interrupting the repetition

System Message: ERROR/3 (/home/runner/work/PyZombis/PyZombis/_sources/lectures/TWP15/TWP15_5_en.rst, line 8)

Error in “activecode” directive: unknown option: “class”.

.. activecode:: python
   :class: python
   :nocodelens:
   :stdin:

   sum = 0
   while True:
       x = int(input("Enter a number (0 to exit): "))
       if x == 0:
           break
       sum = sum + x

   print("Sum: %d" %sum)

System Message: ERROR/3 (/home/runner/work/PyZombis/PyZombis/_sources/lectures/TWP15/TWP15_5_en.rst, line 26)

Error in “activecode” directive: unknown option: “class”.

.. activecode:: python
   :class: python
   :nocodelens:
   :stdin:

   sum = 0
   n = 0
   while True:
       x = int(input("Enter a number (0 to exit): "))
       if x == 0:
           break
       else:
           n = n + 1
       sum = sum + x

   print("Average: %5.2f" %(sum / n))
You have attempted of activities on this page