Q:

How do I add more than 2 sprites into an animation in pygame?

#Importing the pygame functions
import pygame 
import sys
import os
from pygame.locals import *

#Allows for the editing of a window
pygame.init() 
#Sets screen size
window = pygame.display.set_mode((800,600),0,32) 
#Names the window
pygame.display.set_caption("TEST") 
#Types of colors (red,green,blue)
black = (0,0,0) 
blue = (0,0,255)
green = (0,255,0)
yellow = (255,255,0)
red = (255,0,0)
purple = (255,0,255)
lightblue = (0,255,255)
white = (255,255,255)
pink = (255,125,125)

clock = pygame.time.Clock()

L1="bolt_strike_0001.PNG"
L1=pygame.image.load(L1).convert_alpha()
L2="bolt_strike_0002.PNG"
L2=pygame.image.load(L2).convert_alpha()
L3="bolt_strike_0003.PNG"
L3=pygame.image.load(L3).convert_alpha()
L4="bolt_strike_0004.PNG"
L4=pygame.image.load(L4).convert_alpha()

lightingCurrentImage = 1

#Loop
gameLoop = True 
while gameLoop:
    for event in pygame.event.get():
        if event.type == pygame.QUIT:
            gameLoop=False #Allows the user to exit the loop/game
    window.fill(black) #used to fill the creen with the certian color variables
    if (lightingCurrentImage==1): 
        window.blit(L1, (0,0))
    if (lightingCurrentImage==2):
        window.blit(L2, (0,0))
    if (lightingCurrentImage==3):
        window.blit(L3, (0,0))
    if (lightingCurrentImage==4):
        window.blit(L4, (0,0))
    if (lightingCurrentImage==2):
        lightingCurrentImage=1
    if (lightingCurrentImage==3):
        lightingCurrentImage=2
    if (lightingCurrentImage==4):
        lightingCurrentImage=3

    else:

        lightingCurrentImage+=3;

    pygame.display.flip() #must flip the image o the color is visable

    clock.tick(5)

pygame.quit() #quit the pygame interface
exit(0)

I'm having problems stitching together 10 images of a lightning bolt animation in pygame. What I have at the moment works but its not what I want it to look like. What happens when I run this is the lightning bolt creates the animation sequence once then disappears and never restarts the sequence again. If I set lightingCurrentImage+=3 to lightingCurrentImage+=2 it appears and stays on the screen but doesn't ever disappear. Please help me to see what the problem is if you can. Thanks! (I want the lightning bolt to begin and go all the way through the animation then disappear. Then begin again and repeat).

A:

First create list of images then you can use it this way:
bold_imgs = []

bold_imgs.append( pygame.image.load("bolt_strike_0001.PNG").convert_alpha() )
bold_imgs.append( pygame.image.load("bolt_strike_0002.PNG").convert_alpha() )
bold_imgs.append( pygame.image.load("bolt_strike_0003.PNG").convert_alpha() )
bold_imgs.append( pygame.image.load("bolt_strike_0004.PNG").convert_alpha() )

lightingCurrentImage = 0

while True:

     # here ... your code with events

    window.fill(black)

    window.blit( bold_imgs[ lightingCurrentImage ], (0,0))

    lightingCurrentImage += 1

    if lightingCurrentImage = len( bold_imgs ):
        lightingCurrentImage = 0

    pygame.display.flip() 

    clock.tick(5)

You can use tick(25) to get faster but smoother animation.
Human eye needs at least 25 images per second to see it as smooth animation.

