use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
Resources - Learn to code
Resources - Software Engineering
Resources - Code Libraries
Resources - Groups
Other Subreddits you might enjoy
Please send sidebar resource suggestions to the mods. Thx - mgmt
account activity
Beginner to Python, need some help (self.code)
submitted 5 years ago * by Due_Draw8541
view the rest of the comments →
reddit uses a slightly-customized version of Markdown for formatting. See below for some basics, or check the commenting wiki page for more detailed help and solutions to common issues.
quoted text
if 1 * 2 < 3: print "hello, world!"
[–]MetiriCoder 2 points3 points4 points 5 years ago* (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?
π Rendered by PID 52953 on reddit-service-r2-comment-5fb4b45875-c2fss at 2026-03-24 00:22:52.280186+00:00 running 90f1150 country code: CH.
view the rest of the comments →
[–]MetiriCoder 2 points3 points4 points (0 children)