Mar-03-2017, 12:47 AM
(This post was last modified: Mar-03-2017, 01:03 AM by sparkz_alot.)
Okay so I'm having trouble finding my problem I know the line of code that Idle is telling me that needs corrected is not the problem, but I can't seem to find what the problem is. Please let me know if you can find it or if I need to post more of my code. Thanks
The Error:
The Error:
Error: File "/home/ryan/Desktop/CS3560/Homework_3/prog3_new.py", line 352, in print_board
line = line + board[row][col] + " | "
IndexError: string index out of range
The code:def print_board(board, count): line = "" if(count > 0): for row in range(0, 4): for col in range(0, 4): if(col == 0): line = line + " " if(col == 3 and row != 3): line = line + board[row][col]+ " \n------------------------\n" elif(col == 3): line = line + board[row][col]+ " " else: line = line + board[row][col] + " | " print line else: for row in range(0, 4): for col in range(0, 4): if(col == 0): line = line + " " if(col == 3 and row != 3): line = line + board[row][col]+ " \n------------------------\n" elif(col == 3): line = line + board[row][col]+ " " else: line = line + board[row][col] + " | " return line