More with 'for'


The error message comes "Error:The program took too long to finish. Check your code for infinite loops and try again."

I expect the loop to work and store the numbers of start_list in square_list, squared, and print square_list

start_list = [5, 3, 1, 2, 4]
square_list = []

# Your code here!
for number in start_list:
    start_list.append( number ** 2)

print square_list


You need parenthesis to use the sort method, so it would look like:


Everything else is good, hope this helps. :slight_smile:


Your code has what is essentially an infinite loop.

The program should append each number ** 2 to square_list.

For best efficiency, sort the square_list after the loop, rather than within it.


All this helped. Thanks.


I just want to say that in my code I put the for loop as: for x in start list:


just saying it also works