I am trying to do a project in python. I'm getting an error in the line
s+=line
TypeError: unsupported operand type(s) for +=: 'int' and 'list'
Here is the function called testIfCorrect:
def testIfCorrect(world, x, y):
s=0
for line in world:
s+=line
print("ligne",line)
if(s > 2):
return False
for i in range(x):
if(sum(returnColumn(world, i)) > 2):
return False
for j in range(x):
for k in range(y):
if(j == k):
pass
else:
if(world[j] == world[k]):
return False
if(returnColumn(world, j) == returnColumn(world ,k)):
return False
def returnColumn(array, column):
return [col[column] for col in array]
Where is the error?
linecontain? What did you expect to happen instead?sis an integer (s=0), but clearlylineis a string, presumably becauseworldis a list of strings or a file, or perhaps one string. - Martijn Pieters♦testIfCorrect. Can you tell the parameters for it. I thinkworldis a list of lists. Please confirm - Barun Sharma