Good friends. The fact is the following, I have a small code of the game hanged, nevertheless every time that its main function is executed it goes advancing downwards leaving the previous action above as it is typical in the terminal. I would like it to be cleaned after entering a letter. Pq if all the attempts are not accumulated and the terminal is full and it is a bit confusing. here the code. I would appreciate your help
import random
import os
IMAGENES=["A ","AH ","AHO ","AHOR ","AHORC ","AHORCA ","AHORCAD
","AHORCADO "]
PALABRAS=[
"lavadora",
"secadora",
"sofa",
"gobierno",
"computadora",
"cubo",
"paralelepipedo"
]
def randomWord():
indiceAlea=random.randint(0,len(PALABRAS)-1)
return PALABRAS[indiceAlea]
def displayBoard(hiddenWord,intentos):
print(IMAGENES[intentos])
print("")
print(hiddenWord)
print("--- * ---- --- * ---- --- * ---- --- * ---- --- * ---- --- * ----
")
def body():
word=randomWord()
hiddenWord=["_"]*len(word)
intentos=0
letrasUsadas=[]
while True:
displayBoard(hiddenWord,intentos)
letraIntro=str(input("Escoge una letra: "))
letrasUsadas.append(letraIntro)
print("Ya ha utilizado las siguientes letras",letrasUsadas)
listLetras=[]
for i in range(len(word)):
if word[i]==letraIntro:
listLetras.append(i)
if len(listLetras)==0:
intentos+=1
if intentos==8:
print("")
print("Usted ha perdido, la palabra era",word)
break
else:
for i in listLetras:
hiddenWord[i]=letraIntro
listLetras=[]
os.system("cls")
try:
hiddenWord.index("_")
except ValueError:
print("")
print("Felicidades, has ganado, la pabra es",word)
break
if __name__ == '__main__':
print("B I E N V E N I D O A A H O R C A D O")
body()
Something like cleaning the terminal manually as it would be in windows with cls. But I do the same program after each iteration of the main while cycle.