Q: Pygame character images swap import pygame, sys
from pygame.locals import * 

try:
    import Android
except ImportError:
    Android = None

try:
    import pygame.mixer as mixer
except ImportError:
    import android.mixer as mixer    

pygame.init()

#Android to cross platform

if Android:
    android.init()
    android.map_key(android.KEYCODE_BACK, pygame.K_ESCAPE)

#Variables

score = 0
health = 100
enemy_x = 0
enemy_y = 0
#Colours

RED = (255 ,0 ,0)
BLACK = (0, 0, 0)

# Left Edge of rectangle, top, width, height
player_rect = pygame.Rect(540, 0, 32, 32)
enemy = pygame.image.load("monster.png")

size = width, height = 1276,650
screen = pygame.display.set_mode(size)

direction ="down"

# This is the score text
gamefont = pygame.font.Font(None, 30)
scoretext = gamefont.render('Player Score: '+ str(score), 2, [255,0,0])
boxsize=scoretext.get_rect()
scoreXpos=(width-boxsize[2])/2  
scoreYpos=(height-boxsize[2])/2  
screen.blit(scoretext, [scoreXpos,20])

# This is the health 
gamefonts = pygame.font.Font(None, 30)
scoretexts = gamefonts.render('Player Health: '+ str(health), 2, [255,0,0])
boxsizes=scoretexts.get_rect()
scoreXposs=(width-boxsizes[2])/2 
scoreYposs=(height-boxsizes[2])/2  
screen.blit(scoretexts, [scoreXposs,20])

PAUSED = False
font = pygame.font.SysFont("serif", 72)
text_paused = font.render("PAUSED", True, (255, 0, 0))


sound = mixer.Sound('maintheme.ogg')
sound.play()


r = 0
bif = pygame.image.load("map5.png") 
pygame.display.set_caption("Pygame 2D RPG !")
x,y=0,0
movex, movey=0,0

character_w = "character_player/character_w.png"
character_a = "character_player/character_a.png"
character_s = "character_player/character_s.png"
character_d = "character_player/character_d.png"

character_w1 = pygame.image.load(character_w).convert_alpha()
character_a1 = pygame.image.load(character_a).convert_alpha()
character_s1 = pygame.image.load(character_s).convert_alpha()
character_d1 = pygame.image.load(character_d).convert_alpha()

clock = pygame.time.Clock()
enemy_speed = 100

while True:

    # --- events ---

    for event in pygame.event.get():

        if event.type == pygame.QUIT:
            pygame.quit()
            sys.exit()


        if event.type==KEYDOWN:
            if event.key == K_ESCAPE:
                pygame.quit()
            sys.exit()
            elif event.key==K_q:
                PAUSED = not PAUSED

        if not PAUSED:
            if event.type==KEYDOWN:
                if event.key==K_a:
                    movex=-10
                    screen.blit(character_a1,(x,y))

                elif event.key==K_d:
                    movex=+10
                elif event.key==K_w:
                    movey=-10
                elif event.key==K_s:
                    movey=+10
            if event.type==KEYUP:
                if event.key==K_a:
                    movex=0
                elif event.key==K_d:
                    movex=0
                elif event.key==K_w:
                    movey=0
                elif event.key==K_s:
                    movey=0


if not PAUSED:
    x+=movex
    y+=movey   
    print x,y
if x in range(680,702) and y in range(377,403):  # This is the location of the tile.
    bif = pygame.image.load("map6.png")
screen.fill((r,0,0))
screen.blit(bif,(0,0))
screen.blit(character_s,(x,y))
screen.blit(enemy, (enemy_x, enemy_y))

milli = clock.tick()
seconds = milli/1000.
dm = seconds*enemy_speed
#enemy_x += dm 


#enemy_x+=10

#if enemy_x>1280:
    #enemy_x = 0

#pygame.draw.rect(screen, RED, player_rect) 

screen.blit(scoretexts, [scoreYposs, 45])
scoretexts = gamefonts.render('Player Health: '+ str(health), 2, [25,25,112])
#health +=10


screen.blit(scoretext, [scoreYpos,70])
scoretext = gamefont.render('Player Score: '+ str(score), 2, [25,25,112])
#score +=10   

if PAUSED:
    screen.blit(text_paused, (100, 100))    

pygame.display.update() 

The image does not change when the a key is pressed, as it is meant to switch to a different image however it does not.  please can someone help me I don't now why it is not changing.
Thanks again for the help

A: Skimming over your code, I think that your image is changing, but you won't be able to see it.  You have the following:
if event.type==KEYDOWN:
    if event.key==K_a:
        movex=-10
        screen.blit(character_a1,(x,y))

So, at the exact moment that you handle the singular key down event that will be generated when pressing a key, you will blit the alternate image to the screen.  ...And then later in that frame you're going to draw over it:
screen.blit(character_s,(x,y))

This line is run by your code every frame, which means that image is always going to draw.  Since it comes after the blit of the alternate image, it will always draw over it.  Even if the blit of the alternate image came after this, it would only be drawn for one frame, because you're only going to be handling one KEYDOWN event per key press.
Try the following pattern:
# Along with the rest of your global variables...
activeCharacterImage = character_s

# The rest of your code...

if event.type==KEYDOWN:
    # When the 'A' key is pressed, switch the character image.
    if event.key==K_a:
        movex=-10
        activeCharacterImage = character_a1

# Some more of your code...

# Your new character drawing call.
screen.blit(activeCharacterImage, (x,y))


A: I also suggest using a "costume" variables and setting it to which image of the character you want to use.
if player_x == 500:
    costume = "james.jpg"

