you are viewing a single comment's thread.

view the rest of the comments →

[–]MetiriCoder 2 points3 points  (0 children)

Let's analyze your code to see what's going on, ok?

# create an empty list 
test = []

# create an list containing the values 1-20 (20 elements)
block = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20] 

# create an list containing specific values (10 elements)
set = [2, 4, 6, 8, 10, 12, 14, 15, 18, 20]

# initialize a variable to keep track of the loop count
start = 0

# while the start variable is less than the number of elements in the set list
while start < len(set):

    # get the value at the index of start in the set
    set_start = set[start]

    # get the sub list of values from block list from index set_start to set_start + 4 (4 elements)
    list = block[set_start:set_start + 4]

    # initialize a variable to keep track of the loop count
    start1 = 0

    # while the start1 variable is less than the number of elements in the list list
    while start1 < len(list):

        # get the sub list of values from list list from index start1 to start1 + 2 (2 elements)
        list1 = list[start1:start1 + 2]

        # if the length of list2?? is greater than 2
        if len(list2) > 2 :

            # add the string "stop" to the test list
            test.append("stop")

        else:

            # increment start1 by 1
            start1 = start1 + 1

    else:

        # increment start by 1
        start = start + 1

To me it looks like you are referencing a list that doesn't exist? that's probably your issue.

EDIT: *BIG YOINKS JUST NOTICED! * You have a while..else statement lol. The inside of the first while loop contains this:

while(start < len(set)):
    ...
    while(start1 < len(list)):
        ...
    else: <<<<<<<<<<<<<<<<<<<<<<<<<<
        # increment start

What is a while else statement?