Why does this make an error and how to fix this??
I'm trying to make a wordle game but on python In repl.it Whenever I try to type a new word after the first one it gives me an error. Traceback (most recent call last): File "main.py", line 58, in <module> checkWord() File "main.py", line 38, in checkWord gameBoard[0][wordIndex] = key.upper() IndexError: list assignment index out of range Link to repl.it (fork it) : https://replit.com/@DenisDziganchuk/Word-Game#main.py code : # © Copyright 2022 by Denis Dziganchuk from colors import colored from getkey import getkey, keys from words import words import os import string word = words[0] gameRunning = True wordMade = False wordIndex = 0 gameBoard = [[" ", " ", " ", " ", " "] for i in range(6)] blank = [["|| |", "| |", "| |", "| |", "| ||"] for i in range(6)] allowed = list(string.ascii_lowercase) allowed.append(keys.ENTER) allowed.append(keys.BACKSPACE) def printGameBoard(): global gameBoard print("-----------------------------------------------") for i in range(6): middle = ["|" + el.center(7) + "|" for el in gameBoard[i]] print("".join(blank[i])) print("|" + "".join(middle) + "|") print("".join(blank[i])) print("-----------------------------------------------") def checkWord(): global wordMade, gameBoard, wordIndex, blank typedWord = "" key = getkey() while key.lower() not in allowed: key = getkey() if key in list(string.ascii_letters): gameBoard[0][wordIndex] = key.upper() wordIndex += 1 elif key == keys.ENTER: wordMade = True typedWord = "".join(gameBoard[0]) for i in range(5): if word[i] == typedWord[i]: blank[0][i] = colored(" ", "grey", "on_green") elif key == keys.BACKSPACE: gameBoard[0][wordIndex - 1] = " " wordIndex -= 1 clearBoard = lambda: os.system("clear") while gameRunning: clearBoard() printGameBoard() checkWord()