You should first create object that you want to have in the game, with one operation being to draw them.
So instead of having a function that draws a pipe and scrolls, you want to have something along these lines:
class Pipe:
def __init__(self,x,height):
self.rect = Rect((x,0),(30,height))
def update():
self.rect.move_ip(-2,0)
def draw(screen):
pygame.draw.rect(screen,color,self.rect)
And then later in game you can have:
pipes = [Pipe(x*20,random.randint(40,270)) for x in range(5)]
for pipe in pipes:
pipe.draw(screen)
pipe.update()
Later on you could just remove the pipes that are not on the screen, and append new ones when a pipe is removed.