Q:

Python 3.2 W/ Pygame Crashes

Well, I was happy starting on Pygame with a bit of knowledge on python, But while i was following some starter tutorials i noticed that, At the moment of running my code the Pygame window didn't see to respond, so i put some "print" commands to see how far did it get, I noticed that it stopped on the Loop, Any ideas on how i can fix it? I will leave the code around here
import pygame
pygame.init()

print("First Fase")
win = pygame.display.set_mode((500,500)) 

pygame.display.set_caption("Test")

print("Second Fase")
x = 50
y =50
width = 40
height = 60
vel = 7

print("Third Fase")

done = False
while not done:
 pygame.time.delay(100)

for event in pygame.event.get():
 if event.type == pygame.QUIT:
  done = True

if event.type == KEYDOWN:
 if event.key == K_ESC:
  done = True

pygame.draw.rect(win, (255, 0, 0), (x, y, width, height))
pygame.display.update()
print("NoErrors")

A:

It has to be pygame.KEYDOWN and pygame.K_ESC rather than KEYDOWN and K_ESC.
But fist of all you have to respect the Indentation. In the following code the loops are not nested:

done = False
while not done:
 pygame.time.delay(100)

for event in pygame.event.get():
 if event.type == pygame.QUIT:
  done = True

The for loop is not in the while, it is a separate loop after the while loop.
You have to format your code like this:   
import pygame
pygame.init()

print("First Fase")
win = pygame.display.set_mode((500,500)) 

pygame.display.set_caption("Test")

print("Second Fase")
x = 50
y =50
width = 40
height = 60
vel = 7

print("Third Fase")

done = False
while not done:
    pygame.time.delay(100)

    for event in pygame.event.get():
        if event.type == pygame.QUIT:
            done = True

        if event.type == pygame.KEYDOWN:
            if event.key == pygame.K_ESC:
                done = True

    pygame.draw.rect(win, (255, 0, 0), (x, y, width, height))
    pygame.display.update()
    print("NoErrors")

