Pygame Accessing variables in functions
<p>Hey I've been trying to call the pygame events in a function to reduce the clutter of my code. But I am unable to perform the process due to an error with global variables. Any help would be appreciated. </p>

<pre><code>from pygame.locals import *
import pygame, sys
def color():
    screen.fill((85,163,48)) 

def events():
for event in pygame.event.get():
    if event.type == QUIT:
        pygame.quit()
    if event.type == pygame.MOUSEBUTTONDOWN and event.button == LEFT:
        print "left"
#sets the game map variables
tilesize = 100
map_width = 600
map_height = 300
#initialises the game screen setting it up with the game map variables
pygame.init()
screen = pygame.display.set_mode((map_width,map_height))

while True:
    color()
    events()
    pygame.display.update()
</code></pre>