I'm in-console Battleship game in Python and I have a code that checks if the ship can fit into the list. It does not look very appealing and I'd like to simplify it into a more appealing version.
if (direction is "N" and row - size < 0) or \
(direction is "E" and column + size > 10) or \
(direction is "S" and row + size > 10) or \
(direction is "W" and column - size < 0):
print("It does not fit")
I was thinking of using the dictionary, but couldn't think of a way to use variables and maths operator (-+ <>) inside
Aucun commentaire:
Enregistrer un commentaire