def parseGrid(string): grid = [[entry.strip() for entry in line.split()] for line in string.split('\n')] for row in grid: for x, col in enumerate(row): try: col = int(col) except: pass if col == "_": col = ' ' row[x] = col return gridworld.makeGrid(grid)