Solution:
In python generally, it throws that NameError if you define the variable. anyway, you've managed to stumble upon a name that already exists in Python. In python, dict is a built-in type like an int. You need to keep in mind that all types are object in python. In the manner, you are trying to index into the type object that’s the reason you are getting the error.
Have a look into the codes below:
d = {1: "walk1.png", 2: "walk2.png", 3: "walk3.png"}
m1 = pygame.image.load(d[1])
m2 = pygame.image.load(d[2])
m3 = pygame.image.load(d[3])
playerxy = (375,130)
window.blit(m1, (playerxy))
I’ve modified your program a little bit and certainly, it works fine.
For better understanding, you may check the python Doc