May-15-2021, 02:07 PM
Think about your logic as well. Your method of creating the list calculates the entire list up to n each time through the loop. So, to get a list of 10 values you generate the list to 3, list to 4, list to 5, etc. Not explaining this well, but if you put a
print('in loop')after line 9 you will see what I mean. An efficient algorithm would only do this 8 times (excludes the first 2 entries).