I am trying to make a pong game, using pygame, following a youtube tutorial and at one point to make the paddle move the guy does this:
def up_down():
    global paddle_1_speed
    if i.type==pygame.KEYDOWN:
        if i.key==pygame.K_w:
            paddle_1_speed-=6
        if i.key==pygame.K_s:
            paddle_1_speed+=6
    if i.type==pygame.KEYUP:
        if i.key==pygame.K_w:
            paddle_1_speed+=6
        if i.key==pygame.K_s:
            paddle_1_speed-=6                             
    return paddle_1_speed,paddle_2_speed
for i in pygame.event.get():
    paddle_1_speed,paddle_2_speed=up_down()
paddle_1.y+=paddle_1_speed
paddle_2.y+=paddle_2_speed
I can't understand why that's working and what's the difference with this:
def up_down() 
    if i.type==pygame.KEYDOWN:
        if i.key==pygame.K_w:
            paddle_1.y-=6
        if i.key==pygame.K_s:
            paddle_1.y+=6
    if i.type==pygame.KEYUP:
        if i.key==pygame.K_w:
            paddle_1.y+=6
        if i.key==pygame.K_s:
            paddle_1.y-=6  
 
for i in pygame.event.get():
    up_down()
The second code just moves the paddle 6 pixels while the key is being hold and when it's released it returns to where it was, which I understand why it's doing that, but I don't get the difference with the first code that moves the paddle just fine. I can post the whole code if needed, any help will be appreciated.
 
     
    