'Is it possible to font.render elements of list in right order pygame?

I don't understand if it possible to show in pygame words one by one from list. I found different ways to show in random order, but in right order I don't know how to do this.

places = ["London", "India", "America", "Australia", "Cambodia", "China",
          "Dubai", "Egypt", "France", "Germany", "Japan", "Jordan",
          "Korea", "Myanmar", "Peru", "Russia", "Singapore", "Spain"]


def text():
    game_font = pygame.freetype.SysFont("monospace", 35)
    text_surface, rect = game_font.render(places[0], (0, 0, 0))
    screen.blit(text_surface, (680, 420))


interval = 2  # Set interval in seconds
last_time = time.time()  # Get the current time in seconds


# Game loop
running = True
while running:
    screen.fill((255, 255, 255))  # RGB
    for event in pygame.event.get():
        if event.type == pygame.QUIT:
            running = False

    #    card()
    # If 2 seconds has past since the last update to last_time
    if time.time() - last_time >= interval:
        for i in places:
            a=i
        last_time = time.time()

    text()
    pygame.display.update()

pygame.quit()

This code shows places in random order. I want to show them in order like London, India etc. Is it possible or no? Because when I try to iterate list it shows me Spain(I don't know why) and stop. Thank you



Solution 1:[1]

The answer is fairly simple it shows Spain because a ends up to be last element of the places list as a ends up to be the last i, You just have to make a variable index before the loop and set its value as 0 and in text function from places[0] convert it to places[index] and than add a line index +=1. Also remove the for loop iterating places

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1