More with "for"


my code works, but I do not understand the sort function.

Why do you not put anything in the parentheses of sort? I thought it should be" sort(square_list) similar how you would use the len function... I do not understand the concept of when there is open parentheses or when you put something inside the parentheses etc.

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

# Your code here!
for number in start_list:


print square_list


if the function has a parameter, you need to supply an argument. sort() doesn't have a parameter, so need for an argument between parentheses.

don't get confused with sorted(square_list), the sorted() function does need an argument.

If a function requires an argument depends how the built in function are coded/designed


Easiest way to understand it for me was to realise that certain functions use the parameter as the list i.e str(variable_name) and len(list_name) but there are functions which have a different format such as variable_name.lower() or variable_name.upper() and the same goes for list_name.append(), list_name.remove() or list_name.sort() in your case. I hope this answers your question.


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