Dec-20-2020, 02:28 PM
I think the indentation should be like this
while running: for game_event in pygame.event.get(): if game_event.type == QUIT: running = False if game_event.type == KEYDOWN: if game_event.key == K_BACKSPACE: if len(text)>0: # if length of text is > 0 text = text[:-1] # delete the last letter in the string else: text += game_event.unicode # else add the letter to the end of the string img = font.render(text, True, RED) rect.size=img.get_size() cursor.topleft = rect.topright screen.fill(background) screen.blit(img, (20, 20)) pygame.display.update()