Python Syntax Error but looks fine to me. Help?
Right now I'm working on a Tetris Game (sorta, I found a Tetris example for Python on a website, I've been copying it but adding some of my own stuff), and just finished writing all the code but have had a couple syntax errors. I've been able to fix all of them but this last syntax error is confusing to me.
def pieceDropped(self):
for i in range(4):
x = self.curX + self.curPiece.x(i)
y = self.curY - self.curPiece.y(i)
self.setShapeAt(x, y, self.curPiece.shape()开发者_如何学编程
self.removeFullLines()
The specific syntax error is on the last line of the function and I don't understand why, the indentation and whitespace all seems correct. So could someone explain how this is a syntax error?
You didn't close the parenthesis of self.setShapeAt
.
There's an extra whitespace on the last line - just ahead self.removeFullLines()
. Its indenting is thus not the same as the for
line's indenting. EDIT: Seems to be corrected now.
Always use the same indent sequence - choose either tabs, or n whitespaces. But be consistent. Some editors (such as VIM) are able to insert the appropriate number of whitespaces whenever you hit tab.
精彩评论