so I'm trying to create the game Yahtzee in python, and I'm trying to put up points inside a table I created. although, because strings are immutable, I tried to retrieve a dictionary item from inside the list (which comprises the table) and concatenate it with the rest of the string. but for some reason my output just excludes the dictionary item as if it's not there.
here is the code:
points = {
"1" : "Ones",
"2" : "Twos",
"3" : "Threes",
"4" : "Fours",
"5" : "Fives",
"6" : "Sixes"
}
avaliable_grid = [
" _____________________________ _____________________________",
"| |Player 1|Player 2| | |Player 1|Player 2|",
"|-----------|--------|--------| |-----------|--------|--------|",
"|Ones |" + points["1"] + "| | |3 of a Kind| | |",
"|-----------|--------|--------| |-----------|--------|--------|",
"|Twos |" + points["2"] + "| | |4 of a Kind| | |",
"|-----------|--------|--------| |-----------|--------|--------|",
"|Threes |" + points["3"] + " | | |Full House | | |",
"|-----------|--------|--------| |-----------|--------|--------|",
"|Fours |" + points["4"] + "| | |S. Straight| | |",
"|-----------|--------|--------| |-----------|--------|--------|",
"|Fives |" + points["5"] + "| | |L. Straight| | |",
"|-----------|--------|--------| |-----------|--------|--------|",
"|Sixes |" + points["6"] + "| | |Chance | | |",
"|-----------|--------|--------| |-----------|--------|--------|",
"|#############################| |YAHTZEE | | |",
"|-----------|--------|--------| |-----------|--------|--------|",
"|Sum | | | |#############################|",
"|-----------|--------|--------| |-----------|--------|--------|",
"|Bonus | | | |TOTAL SCORE| | |",
" ----------------------------- ----------------------------- ",
]
def print_table(table):
for i in table:
print(i)
print_table(avaliable_grid)
output:
_____________________________ _____________________________
| |Player 1|Player 2| | |Player 1|Player 2|
|-----------|--------|--------| |-----------|--------|--------|
|Ones | | | |3 of a Kind| | |
|-----------|--------|--------| |-----------|--------|--------|
|Twos | | | |4 of a Kind| | |
|-----------|--------|--------| |-----------|--------|--------|
|Threes | | | |Full House | | |
|-----------|--------|--------| |-----------|--------|--------|
|Fours | | | |S. Straight| | |
|-----------|--------|--------| |-----------|--------|--------|
|Fives | | | |L. Straight| | |
|-----------|--------|--------| |-----------|--------|--------|
|Sixes | | | |Chance | | |
|-----------|--------|--------| |-----------|--------|--------|
|#############################| |YAHTZEE | | |
|-----------|--------|--------| |-----------|--------|--------|
|Sum | | | |#############################|
|-----------|--------|--------| |-----------|--------|--------|
|Bonus | | | |TOTAL SCORE| | |
----------------------------- -----------------------------
for some reason, the points[] dictionary is ignored. also, the way I am printing this is like that because I want it to print row by row, without parenthesis, or quotation marks.
for reference- I am using python 3.8.2, and I'm working through IDLE.