Skip to content

Instantly share code, notes, and snippets.

@Sparrow1029
Created November 12, 2017 20:13
Show Gist options
  • Save Sparrow1029/9f5f4a4039718edbdfe4ece9b5f18a53 to your computer and use it in GitHub Desktop.
Save Sparrow1029/9f5f4a4039718edbdfe4ece9b5f18a53 to your computer and use it in GitHub Desktop.
(PracticePython) Drawing a gameboard with number of squares based on user input
#!/usr/bin/env python3
#-*- coding: utf-8 -*-
"""
Ask user size of gameboard and print to screen
"""
while True:
try:
size = int(input("How many squares on a side? "))
except ValueError:
print("\nEnter a number.\n")
continue
break
horz = ' ---'
vert = '| '
x = ''.join([horz] * size)
y = ''.join([vert] * size)
for i in range(size):
print("{}\n{}|".format(x, y))
print(x)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment