pygame.quit is inside your loop. This means that after one iteration of your main run-loop
pygame.quit
After pygame.quit, pygame will no longer be ready for any calls.
pygame
You would get similar errors if you forgot to call pygame.init().
pygame.init()