Whats wrong with my code?


#1



board = []
#FOR LOOP TO CREATE A GRID OF 5*5
 for loop in range(0,5):
     board.append(["O"] * 5)

print board
    
"""File "python", line 3
    for loop in range(0,5):
   ^
IndentationError: unexpected indent
"""


#2

You have a space before the for statement.

> """
> File "python", line 3       ### this is telling you where the error happened.
>     for loop in range(0,5): ### This is the line with the error
>    ^                        ### This is where exactly is thinks the error is in the line.
> IndentationError: unexpected indent  ### This is the type of error and some information about it
> """

As you can see, the error given gives you a lot of information. Try to learn to understand them, it will save you a lot of time and hassle.


#3

I know what it means. My question was "whats wrong with my code", if you can please provide a rectified version of code so that I will not get same error.


#4

With all due respect if you knew what it meant then you would know what was wrong with your code and how to fix it.

Also, I answered your question "What's wrong with my code":

You have a space before the for statement.

But sure, something you can just copy and paste:

board = []
#FOR LOOP TO CREATE A GRID OF 5*5
for loop in range(0,5):
     board.append(["O"] * 5)

print board

#5

please don't get offended. my net connection is not fast enough hence the page was not able to load properly. i, unfortunately, didnt read your soution i just read your comment.


#6

Just remove an additional space before your 'for'.
And it's going to work:slight_smile:


#7

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