More with For


#1

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

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

square_list.sort()
print square_list

Any help would be appreciated. I keep getting this error message “Make sure not to modify start_list!” Thank you!


#2

Double check your for-loop statement. You seem to be assigning the value of each item in start_list to… start_list! Once you’ve made that change, make sure to change your .append() statement as well.


#3

Okay thank you very much!


#4

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
square_list.sort()
print square_list


#5

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