- Write a for loop that will take in a number
- When the loop is called it will iterate forward towards that number and print all the values in between to the console
- Write another loop that will do the same thing but iterate backwards from that number to zero
- Write a for loop that will take in a number.
- When the loop is called it will iterate from
0
forward towards that number and print all the values in between to the terminal. - Write another loop that will do the same thing but iterate backwards from that number to zero.
For example, if we have the following starter code:
def my_loop(x):
# write your code here
# you'll have to delete "pass"
pass
You'll write a loop with the my_loop
function that will iterate from 0 to x and print out all values in between. For example:
[input]
my_loop(10)
[output]
1
2
3
4
5
6
7
8
9
In the next part, you'll write a function that will do the opposite. That is, you'll write the my_reverse_loop
function that will contain a loop that will iterate from x to 0
and print out all the values in between. For example:
[input]
my_reverse_loop(5)
[output]
4
3
2
1