More with 'For'


#1

Help please! I don't think I'm doing it right.

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

for numbers in start_list:
start_list.append(x ** 2)
start_list.sort()
print square_list

Thanks,


#2

Why do you think there's something wrong about it?

Indentation is definitely missing, if you mean that you're using other code then you'll have to share that


#3

I have similar code with proper indentation, but I am getting a potential infinite loop message... any ideas where the loop is coming from?

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

Your code here!

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


#4

yeah
you have used starter_list instead of square_list
so the code should be

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

#5

Here is ur Code:

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


#6

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