Skip to content

Instantly share code, notes, and snippets.

@therealprocyon
Last active July 30, 2019 15:26
Show Gist options
  • Save therealprocyon/3e34788db070164cdfb3a5cc30eb9ca9 to your computer and use it in GitHub Desktop.
Save therealprocyon/3e34788db070164cdfb3a5cc30eb9ca9 to your computer and use it in GitHub Desktop.
Some board drawing function in text
#!/usr/bin/env python3
def draw_board(width, length):
for x in range(length):
print(" ---" * width + " ")
print("| " * width + "|")
print(" ---" * width + " ")
def validate_size(width):
try:
width = int(width)
return width
except ValueError as e:
if not width:
print("Boardsize can't be empty.")
exit(1)
else:
print("Boardsize is not a valid integer.\n\n" +
"Run the program again to solve this\n\n")
exit(1)
def main():
width = input("Enter a single number for the boardsize: ")
width = validate_size(width)
length = width
draw_board(width, length)
if __name__ == '__main__':
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment