For Loop Error


#1

Hello Team,

I am doing the below exercise
https://www.codecademy.com/courses/python-beginner-en-pwmb1/1/6?curriculum_id=4f89dab3d788890003000096#

and my code is like this

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

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

But I am getting error like below.Please help me

File "python", line 5
square_list.append(x**2)
^
IndentationError: expected an indented block


#2

to place something inside a loop, it needs indention. Its common to use 4 spaces

The error is pretty self explaining?


#3

Yes..My bad....thanks corrected it


#4

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