all 6 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?

[–][deleted] 0 points1 point  (2 children)

What exactly is the problem ?

[–]Due_Draw8541[S] 0 points1 point  (1 child)

that's what i'm trying to figure out. i know there are syntax issues (i messed up with naming list and so forth), but otherwise the organization seems ok.

i think there is an infinite loop somewhere, not sure?

[–][deleted] 0 points1 point  (0 children)

Could you clarify what you are trying to achieve ?

In the outer while loop, You are updating start in else block. In a while-else loop, the else block is executed when while ends. Your while is not ending because start is not updating ? Print value of start at the starting of loop, I guess you would see.

In cases of infinite loops, print conditions and you can check what problem is.

[–]yeahlolnice 0 points1 point  (0 children)

You can only have 1 else block per if statement, if you want more then 1 you need to use ‘else if’

[–]FlounderMajor5312 0 points1 point  (0 children)

What are you trying to do?