Any ideas as to why it won't change image to IMG_1? Is it because the variable is declared in the main function?
from pygame import *
from pygame.locals import *
import pygame
import time
import os
def main():
while 1:
#search for image
imageCount = 0 # Sets Image count to 0
image_name = "IMG_" + str(imageCount) + ".jpg" #Generates Imagename using imageCount
picture = pygame.image.load(image_name) #Loads the image name into pygame
pygame.display.set_mode((1280,720),FULLSCREEN) #sets the display output
main_surface = pygame.display.get_surface() #Sets the mainsurface to the display
main_surface.blit(picture, (0, 0)) #Copies the picture to the surface
pygame.display.update() #Updates the display
time.sleep(6); # waits 6 seconds
if os.path.exists(image_name): #If new image exists
#new name = IMG + imagecount
imageCount += 1
new_image = "IMG_" + str(imageCount) + ".jpg"
picture = pygame.image.load(new_image)
if __name__ == "__main__":
main()