The below code makes the window not respond when started.. I wanted to make hangman game and I got the logic done and I was just trying to make the window pop up and its not responding. Also when I run the program, when I type in the letter and type another one then it erases the previous letter a writes the new letter with the underscores. How can I make it so that it keeps the previous letter and prints it with the new letter?
import pygame
pygame.init()
running = True
window_width = 600
window_height = 600
window = pygame.display.set_mode((window_width, window_height))
clock = pygame.time.Clock()
word = "something"
while running:
dt = clock.tick(60)
for event in pygame.event.get():
if event.type == pygame.QUIT:
running = False
answer = ""
guessed = []
guessed.append(input("write your letter here -> "))
for i in word:
if i in guessed:
answer += i + " "
else:
answer += "_ "
print(answer)
answer = ""
pygame.quit()