Help please, trying to understand this Python code


#1

Hello everyone, i’m new at coding with python and i do not understand what the .append() part does?
This exercise is from the learn python “More with For” at code academy.

Write a for-loop that iterates over start_list and .append()s each number squared (x ** 2) to square_list.

Then sort square_list!
start_list = [5, 3, 1, 2, 4]
square_list = []

for number in start_list:
square_list.append(number ** 2)
square_list.sort()

print square_list

I just want to understand what is .append() used for in this code. Thanks in advance!!!


#2

if there is a function or method you do not understand, documentation exists?

append adds items to the end of the list.


#3

thank you so much, I get it now. Thanks for the fast reply!
Cheers!!!


#4

You might not always get a reply so fast, so learning to find and read documentation is still a skill you should teach yourself


#5

Got it thank you so much again!!!