Created
November 12, 2017 20:13
-
-
Save Sparrow1029/9f5f4a4039718edbdfe4ece9b5f18a53 to your computer and use it in GitHub Desktop.
(PracticePython) Drawing a gameboard with number of squares based on user input
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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