0

How to replace every '.' between two columns by an empty space?

def creer_tableau(joueurs, murs): tableauV = [["." for _ in range(17)] for _ in range(9)] tableauH = [['.' for _ in range(35)] for _ in range(9)] # Ajouter les positions des joueurs for joueur in joueurs: x, y = joueur['pos'] if joueur == joueurs[0]: tableauV[y-1][2*x-2] = str(1) if joueur == joueurs[1]: tableauV[y-1][2*x-2] = str(2) # Ajouter les murs horizontaux for mur in murs['horizontaux']: x, y = mur tableauH[y-1][4*x-4] = '-' tableauH[y-1][4*x-3] = '-' tableauH[y-1][4*x-2] = '-' tableauH[y-1][4*x-1] = '-' tableauH[y-1][4*x] = '-' tableauH[y-1][4*x+1] = '-' tableauH[y-1][4*x+2] = '-' # Ajouter les murs verticaux for mur in murs['verticaux']: x, y = mur tableauV[y-1][4*x - 3] = '|' tableauV[y][4*x - 3] = '|' tableauH[y][4*x-5] = '|' # Créer la grille lignes = [] for i in reversed(range(9)): ligne = f"{i+1} | " ligne += " ".join(tableauV[i]) ligne += " |\n |" + ''.join(tableauH[i]).replace('.', ' ') lignes.append(ligne + '|') grille = " -----------------------------------\n" grille += "\n".join(lignes) +'\n' grille += "--|-----------------------------------\n" + " 1 2 3 4 5 6 7 8 9\n" return grille test it with this: joueurs = [ {"nom": "Robin", "murs": 10, "pos": [5, 1]}, {"nom": "Alfred", "murs": 10, "pos": [5, 9]}, ] murs = { "horizontaux": [], "verticaux": [], } print(creer_tableau(joueurs, murs)) you'll se the '.' between two lines that i am talking about

14th Mar 2023, 3:57 PM
Yann Yapi
3 Answers
+ 2
May you please post your code as a link to a codebit instead? It is hard to read a large block of text without any syntax highlights (plus, it'll be easier to translate your comments that are not in english cause we'll copy and paste).
14th Mar 2023, 4:01 PM
Justice
Justice - avatar
+ 1
Hi, Yann Yapi ! You can take a look at this code. Maybe it gices you some ideas with your grid: https://code.sololearn.com/cGI2brufY6BO/?ref=app
14th Mar 2023, 5:26 PM
Per Bratthammar
Per Bratthammar - avatar
0
ohh sorry for the delay but i dont need help anymore but thank you sir
16th Mar 2023, 9:14 PM
Yann Yapi