If it was alright to keep the input below the console, you could use a class to keep your canvas in an array and just render it when you need to.
Here is an example:
#X-Drawer class Canvas: def __init__(self, w, h): self.w = w self.h = h self.c = [] for i in range(w * h): self.c.append(' ') print len(self.c) def render(self): u = 0 s = "" for i in range(len(self.c)): s += self.c[i] if not i % self.w: s += "\n" print s def drawX(self, x, y): n = [(x, y), (x + 1, y + 1), (x + 2, y + 2), (x + 2, y), (x, y + 2)] for i in n: v = i[0] * self.w + i[1] if v < len(self.c): self.c[v] = 'X' def drawLine(self, x, d): n = [] if d: n = [(x, y), (x + 1, y + 1), (x + 2, y + 2)] else: n = [(x, y), (x + 1, y + 1), (x + 2, y + 2)] for i in n: v = i[0] * self.w + i[1] if v < len(self.c): self.c[v] = 'X' def clearScreen(): for i in range(64): print c = Canvas(25, 25) while True: clearScreen() c.render() i = raw_input("Coordinates: ").split() c.drawX(int(i[0]), int(i[1]))
You could also replace the clearScreen with an os call to clr ( How to clear the interpreter console? ) instead of printing 64 lines.
Note: My example uses the drawX function, you could use the drawLine function and different coordinates to draw the lines.