9. More with 'For'


#1



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

for item in start_list:
start_list.append(item ** 20)
start_list.sort()

print start_list


https://www.codecademy.com/en/courses/python-beginner-en-pwmb1/1/6?curriculum_id=4f89dab3d788890003000096


It takes to long to run it says, (Check for infinite loops)


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


Replace this line with your code.


#2

the code you wrote is raising the number to the 20th power not squaring it make sure to change that! Also be very careful with your indentation. when you're printing squarelist at the end it should not be indented and should line up with your "for item in start_list" line. However, startlist.append and startlist.sort should be indented.


#3

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