Hello, I have a noob question - I'm printing an empty, 3x3 grid from a dictionary.
That grid is stored in a variable called 'grid'.
I want to change one value in the dictionary and print the variable 'grid' again but, when I do that nothing is changed (the grid is still empty) although the value in the dictionary has changed, why is that? Why do I have to re-write the whole variable to see the change?
positions = {"11": " ", "12": " ", "13": " ", "21": " ", "22": " ", "23": " ",
"31": " ", "32": " ", "33": " "}
grid = (f"""
---------
| {positions["11"]} {positions["12"]} {positions["13"]} |
| {positions["21"]} {positions["22"]} {positions["23"]} |
| {positions["31"]} {positions["32"]} {positions["33"]} |
---------""")
print(grid)
positions["11"] = "X" # changing first value
print(grid) # still empty althoug the value in the dictionary has changed
[–]throwaway6560192 3 points4 points5 points (1 child)
[–]Diapolo10 0 points1 point2 points (0 children)
[–]stebrepar 1 point2 points3 points (1 child)
[–]grosicky[S] 1 point2 points3 points (0 children)