In most programs that count upwards, the counting begins at 0
.
Write a program counting_0_to_9.py
that uses a counter variable (probably i
) and a while
loop to print out the numbers from 0
to 9
. After that, print a message indicating how many times the loop ran. (Did the loop run nine times or ten?)
Extension
Modify your program so that a variable n
is set at the beginning of the program:
n = 13 # example
Then modify the rest of your program so that it prints out the numbers 0
to n - 1
, as well as a message indicating how many times the loop ran.