Question: there's an example in Learn Python The Hard Way -- Python -- That I'm working on and I just couldn't quite think through it. I think I'm hiccuping on the theoretical elements of changing the program more than the writing the physical lines, but I could be completely wrong.

```
i = 0
numbers =[]
while i < 6:
    print "At the top i is %d" %i
    numbers.append(i)

    i += 1
    print "Numbers now: ", numbers
    print "At the bottom i is %d" %i

print "The numbers: "
for num in numbers:
    print num

```

This is the code that I'm working with and the question/ prompt reads as follows: 

> 
> Convert this while-loop to a function that you can call, and replace 6 in the test (i < 6) with a variable.
> 
> 
> 

If you can help and secondarily write out the significance of each line in layman's terms, that'd be of great help to me. 

Here is my first attempt:

```
def whilefunc(i):
    numbers = []
    for i in range(0,6):
        print "At the top i is %d" %i
        numbers.append(i)
        i += 1
        print "Numbers now: ", numbers
        print "At the bottom, i is %d" %i
    for num in numbers: 
        print num

```

Answer: 
It asks you to imitate a while loop with function calls. You just need to call the function itself recursively.

```
def f(i,x,numbers):
    if (i < x):
        print "At the top i is %d" %i
        numbers.append(i)

        i += 1
        print "Numbers now: ", numbers
        print "At the bottom i is %d" %i
        f(i,x,numbers)
    return numbers

numbers = f(0,6,[])
for num in numbers:
    print num

```

**Output:**

```
At the top i is 0
Numbers now:  [0]
At the bottom, i is 1
At the top i is 1
Numbers now:  [0, 1]
At the bottom, i is 2
At the top i is 2
Numbers now:  [0, 1, 2]
At the bottom, i is 3
At the top i is 3
Numbers now:  [0, 1, 2, 3]
At the bottom, i is 4
At the top i is 4
Numbers now:  [0, 1, 2, 3, 4]
At the bottom, i is 5
At the top i is 5
Numbers now:  [0, 1, 2, 3, 4, 5]
At the bottom, i is 6
0
1
2
3
4
5

```
As @alwayslearnedstuff answered I guess it's true that ZED SHAW didn't meant to create a function that works like a while loop instead of using while loop. But I miss understood that and after trying for a long time I made that using for loop inside. I just want to share my interesting code here although you already have gotten your answer.

```
def function_as_while(length):
numbers = []
for i in range(length):
    print(f"At the top i is {i}")
    numbers.append(i)
    print(f"numbers now: {numbers}")

return numbers
numbers = function_as_while(int(input("Enter list length:  ")))
print("The numbers: ")
for number in numbers:
    print(number)

```

What I did is I created a Function that works as a while loop. And for more fun I gave the `length` parameter with a value that I took as input from user by `int(input("Enter list length: "))` this little part. 

I hope you liked it!!