My current function checks if there is at least a certain amount of characters i.e. If I have a 3x3 square grid, it will check if there is 3 characters or more but I want to modify the code to check if its EXACTLY 3 characters not more.
def double(char):
rows = len(char)
for row in char:
if (len(set(row)) != rows):
return False
return True
It's different to when i check for a square grid:
def square(sq):
rows = len(sq)
for row in sq:
if (len(row) != rows):
return False
return True
In my main code; i raise the exception and call the error:
if not double(d):
raise ValueError
break
except ValueError:
if not square(d):
print("The format is incorrect; Has to be in a n x n square format")
elif not double(d):
print("The grid does not contain exactly n amount of characters")