########################################################################
#        IMPORT STATEMENT BELOW                                            #
########################################################################

import csv

########################################################################
#        HELPER FUNCTIONS                                              #
########################################################################

def set_stage():
    """ Sets the stage, time, and gets the player's name """

    time = 0
    time_display = codesters.Display(time)
    stage.set_background("space")
    stage.disable_all_walls()
    ufo = codesters.Sprite("ufo")
    ufo.set_size(0.5)
    player_name = ufo.ask("Please enter your name.")
    ufo.say(player_name)
    return ufo, player_name, time_display, time

def play_game():
    """ Play game until user gets hit """

    ufo, player_name, time_display, time = set_stage()
    add_sprite_events(ufo)
    
    while not is_hit:
        wait_time = round(1.0/(1 + time/10.0), 1)
        time += wait_time
        time_display.update(time)
        y = random.randint(-225, 225)
        meteor = codesters.Sprite("meteor1", -400, y)
        meteor.set_x_speed(10 + time/5.0)
        meteor.set_size(0.5)
        stage.wait(wait_time)
    return player_name, float(time)

def add_sprite_events(sprite):
    """ Add the key and collision event to sprite """

    global is_hit
    is_hit = False
    def collision(sprite, hit_sprite):
        global is_hit
        is_hit = True
        hit_sprite.hide()
        sprite.turn_right(360)
        sprite.hide()
    sprite.event_collision(collision)
    def left_key():
        sprite.set_x(sprite.get_x() - 20)
    stage.event_key("left", left_key)
    def right_key():
        sprite.set_x(sprite.get_x() + 20)
    stage.event_key("right", right_key)
    def up_key():
        if sprite.get_y() < 215:
            sprite.set_y(sprite.get_y() + 20)
    stage.event_key("up", up_key)
    def down_key():
        if sprite.get_y() > -215:
            sprite.set_y(sprite.get_y() - 20)
    stage.event_key("down", down_key)
    
def sort_by_score(data):
    """ Sort a list of lists by it's second column """

    data.sort(reverse = True, key = lambda x: x[1])

########################################################################
#         CSV AND FILE OPEN                                            #
########################################################################
def get_high_scores(file_name):
    """ Returns data from CSV as list of lists """
    my_file = open(file_name, "r")
    csv_contents = []
    my_data = csv.reader(my_file)
    for row in my_data:
        print(row)
        row[1] = float(row[1])
        csv_contents.append(row)
        
    print("")
    my_file.close()
    return csv_contents
    
def update_high_scores(file_name, my_data):
    """ Uses list of lists to write to new file """
    my_file = open(file_name, "w")
    data_writer = csv.writer(my_file)
    for row in my_data:
        data_writer.writerow(row)
    my_file.close()

########################################################################
#        MAIN FUNCTION                                                 #
########################################################################
def main():
    """ Sets up the program and calls other functions """
    player_name, time = play_game()
    data = get_high_scores("updated_scores.csv")
    data.append([player_name, time])
    sort_by_score(data)
    print(data)
    update_high_scores("updated_scores.csv", data)
    new_data = get_high_scores("updated_scores.csv")

main()


########################################################################



Now customize and extend your project! Make sure to meet these minimum technical requirements:

Write a new function in your code called display_high_scores() that takes in one parameter called data.
Inside display_high_scores(), use a method of your choice to display the contents of data.
Call display_high_scores() at the bottom of main() and make sure to pass in new_data as the parameter.