9 more with 'for'


I would like to find out what wrong with my code


I have try to print out "x", it work finely in 1st place, but when append into square_list the result of "x" have change back to the original data in start_list. and the system give me this error

  Oops, try again. It looks like square_list has 2 at index 1 instead of 4.

is there any Loop expert can tell me what wrong with my code? I not asking the correct answer for just passing the quest

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

# Your code here!
for x in start_list:
    print x ** 2
print square_list


Hi @systemcoder31536 ,

Here, you are printing x ** 2, but then appending x to square_list, without squaring it ...

    print x ** 2

Also consider when you should sort the new list. Currently, you are sorting square_list within the loop.


Python is indentation sensitive. Don't indent square_list.sort() and your code should work! :slight_smile:


This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.