I am confused I came up with the same code and it will not work doesn’t give me any errors just takes awhile for it to just say it is wrong.

when i enter it in repl.it it gives me this

Traceback (most recent call last):
File “python”, line 9
print square_list
SyntaxError: Missing parentheses in call to ‘print’

9. More with 'For'

May we see your code, please?


I had to add the arrow to show that I indented it because it doesnt show on here

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

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


print square_list


That will create an infinite loop. You are appending the wrong list, and it should not be an assignment.

square_list.append(number ** 2)

See the difference?

As you may have discovered, the return value of append() is None. There is nothing to assign. Methods are like that a lot of the time. They act upon their object directly, in a single statement.


You are correct, thank you, I fixed my coding and it was successful!


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