add function before while loop and this after function.
try.
background = create_background(size)Line 62 replace screen.fill(WHITE).
screen.blit(background, (0,0))
imagelist = [filename for filename in cd.iterdir() if filename.suffix in ['.png', '.jpg', '.bmp']] starChoice = (random.choice(imagelist))imagelist filename is a pathlib class. It is not a string.
try.
StarColor = pygame.image.load(str(starChoice))
99 percent of computer problems exists between chair and keyboard.