Issue
Following code compiles without any error:
class game:
def __init__(self, filePath):
self.gameState = readGame.readGameState(filePath)
But when I modify it to
class game:
def __init__(self, filePath = None):
if filePath is None:
self.gameState = [[0 for x in range(7)] for x in range(7)]
else:
self.gameState = readGame.readGameState(filePath)
Here the intention is to call class constructor with or without filePath. The file contains 7x7 matrix and hence I've initialized game state with empty matrix if filePath is not passed. But I am getting IndentationError: expected an indented block. what's fundamentally wrong here. I've tried hard but not able to debug it.
Solution
You are mixing tabs and spaces in the last line -
self.gameState = readGame.readGameState(filePath)
It shows that it has first 4 spaces, then a tab and then again 4 spaces, whereas all other lines you have only use spaces for indentation.
You should not be mixing tabs and spaces , I would advice you to consistently use spaces for indenting that line as well.
Answered By - Anand S Kumar
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.