I have the following code:
board_dic = {
0: '_',
1: '_',
2: '_',
3: '_',
4: '_',
5: '_',
6: '_',
7: '_',
8: '_',
}
print("|{0}|{1}|{2}|\n|{3}|{4}|{5}|\n|{6}|{7}|{8}|".format(**board_dic)
The output when running is:
line 28, in <module>
print("|{0}|{1}|{2}|\n|{3}|{4}|{5}|\n|{6}|{7}|{8}|".format(**board_dic))
IndexError: Replacement index 0 out of range for positional args tuple
I can't find a solution to this anywhere. If I was to replace the keys in board_dic to strings, such as 'a', 'b', 'c', etc. and replace the placeholders in the print statement to 'a', 'b', 'c', etc. then my print statement would execute without any issues. However, it seems that the problem is specifically with numerical key dictionary values.
Why is this so, and how can I fix it?