More with "for"


#1

I am terrible with following and understanding directions so I attempt it my own way and its not working out. My coding seems to make sense and follows the directions (at least thats what I think). I need a little help, I'm still new to learning Python so please take it easy. Attached is a screen shot of the exercise if you cant see clearly here are the directions;

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

Here is what I have.

start_list = [5, 3, 1, 2, 4]
square_list = []
square_list.sort()
for start_list in square_list.append(x ** 2):
    
    print square_list

#2

Hello, @user_beck!
The idea of your code is correct, you're getting an element, putting into the new list and calculating it, great!
But you can't use the append() function on the for loop statement, not sure if you can do on other languages but sure you can't in Python and C++.
Also, you'll need a variable to iterate through your list with the numbers, using an empty list to iterate through another list is not possible, as far as I know.

Try putting in the "normal" way:

for someVariable in start_list:
    square_list.append(someVariable ** 2)
print square_list

#3

@g4be thank you for the explanation. I followed your directions and figured it out. Thank you.