Python Lists and Dictionaries 9. Help


Good Morning to you all Ladies and Gents I have come across a problem I need assistance with:

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

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

print square_list

This is the code I have now I know that number is not a valid syntax, but how am I suppose to .append()
every number in start_list to square_list and make every number go through the exponent of two?


Hello @youcantstopit,

The value that you want to append to a list should be inside the parentheses of the method. For instance


Hope this clears things out for you...


Explain here what the value is and where I put the ** 2 because I was kinda confused as to why you would put code like

for animal in animals:

see animals is a list but how does the computer know what animal is or is it referring to what's in the list
as in you could put anything after for as long as the list name is specified


Hey @youcantstopit,

In pythons for loops, you can use any variable in for loop to define the individual member of the list over which the for loop is iterating over. The value that you are append()ing to the list is number ** 2 which should be put inside the parentheses... Hope this fixes your problems.


Yes it did thank you for helping me have a wonderful day!