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: 
I'm late to this question, but I too am taking this class and thought I could add to the discussion. I think the below code correctly answers 1-3 of the study drills for this lesson.

```
    numbers = []
    def numbers_list(x,y):
        i = 0
        while i < x:
            print "At the top of i is %d" % i
            numbers.append(i)
            i += y
            print "Numbers now: ", numbers
            print "At the bottom of i is %d" % i
        return numbers

    numbers_list(6,1)
    print "the numbers: "

    for num in numbers:
        print num

```

Output will be the same as above.
```
# get the input from the user for i
i = int(input("i>"))
# create an empty list and fill it later
numbers = []
# get input from user for the variable to use in while
num = int(input("num>"))
# Create a function and use while loop
def yourfunction(i):
    while i < num:
        # if user input for "i" is less than the user input for "num"
        print(f"at the top of i is {i}")
        # once i is printed, Add i to the list
        numbers.append(i)
        #once i is added to the list, print the list
        print("numbers now", numbers)
        # Then increment i by 1
        i = i + 1
        #once incremented, print i and repeat
        print(f"At the bottom of i is {i}")
# Call the function
yourfunction(i)
# print the newly created list
print(f"the new list is {numbers}")
# use of for loop 
for num in numbers:
    print(num)][1]

```

Output is available in the below link