0

tic tac toe game TypeError

I was trying to make a simple tic tac toe game and I am always stumbling open a TypeError: "not all arguments converted during string formatting" I tried putting the player_turn()'s block of code in the main() while but that isn't working either. Any ideas what might be the reason for the incorrect execution?? https://code.sololearn.com/cMoDPxDXYfno/?ref=app

28th Jan 2020, 4:48 PM
Azmat
4 odpowiedzi
+ 1
on the player turn you change the board list value to O (or X). that means value%3 in print board function no longer valid when it reach the element that has been replaced by the player (O|X). since the value is no longer a number. you should itterate the board by the index not by value
28th Jan 2020, 5:30 PM
Taste
Taste - avatar
+ 1
its for index, value in enumerate
29th Jan 2020, 3:40 PM
Taste
Taste - avatar
0
Taste thanks it worked by iterating by index (i used range(len)) I still have a question though why did the following replacement didn't work: def print_board(board): for value, index in enumerate(board, start=1): print(f'{value:^3}', end='\n\n' if index % 3 == 0 else '-')
29th Jan 2020, 3:31 PM
Azmat
0
Taste ah silly me, Thank you for the help.
29th Jan 2020, 4:04 PM
Azmat