Python - Race Results - Issues sorting dictionay entries and printing out data in particular form
Question: FYI I am new to python and there could be a more efficient way to produce the
desired results. Please feel free to suggest an alternative method.

Problem 1 - I cannot figure out a way to add "1st Place:, 2nd Place:, etc." to
output 1

Problem 2 - I cannot figure out why, in output 2, I cannot get the time to
print.

    
    
    import os
    
    os.system('cls')
    
    #**********************************************
    # The goal of this script is to collect both a racers name and finish time. When the last
    # racers data is entered the script will order the names of racers (i.e. First, Second,
    # Third) based on time (less time is better.) and print the ordered results to the screen.
    # The race times will be entered as integers.
    
    #**********************************************
    
    # Sample input:
    
    # What is the first racers name: Larry 
    
    # What is the first racers time: 12
    
    # What is the second racers name: Moe 
    
    # What is the second racers time: 9
    
    # What is the third racers name: Curly 
    
    # What is the third racers time: 20
    
    
    # Sample output:
    
    # 1st Place: Moe
    
    # 2nd Place: Larry
    
    # 3rd Place: Curly
    
    #**********************************************
    
    
    print ('\n')
    
    print ('\n')
    
    
    # Enter the first racers name
    
    racer_name_1 = input("Enter racer number one's name: ")
    
    
    # Enter the first racers time 
    
    racer_time_1 = int(input("Enter racer number one's time: "))
    
    
    # Enter the Second racers name
    
    racer_name_2 = input("Enter racer number two's name: ")
    
    
    # Enter the Second racers time 
    
    racer_time_2 = int(input("Enter racer number two's time: "))
    
    
    # Enter the Third racers name
    
    racer_name_3 = input("Enter racer number three's name: ")
    
    
    # Enter the Third racers time 
    
    racer_time_3 = int(input("Enter racer number three's time: "))
    
    
    # Create the race results dictionary
    
    raceList = {racer_name_1:"racer_time_1", racer_name_2:"racer_time_2", 
    racer_name_3:"racer_time_3"}
    
    
    print ('\n')
    
    # This is output 1
    for value in sorted(raceList, reverse=True):
    print (value)
    
    
    print ('\n')
    
    # This is output 2
    print (raceList)
    
    
    print ('\n')
    
    print ('\n')
    


Answer: **Question 2**

You don't need quotes here, or the values will be interpreted as string
literals, which they are

    
    
    raceList = {racer_name_1:"racer_time_1",
                racer_name_2:"racer_time_2", 
                racer_name_3:"racer_time_3"}
    

Just use your variables as the values

    
    
    raceList = {racer_name_1: racer_time_1,
                racer_name_2: racer_time_2, 
                racer_name_3: racer_time_3}
    

**Question 1**

Make a list of tuples like (name, time)

    
    
    racers = [(i, raceList[i]) for i in raceList]
    

Sort that list by their times

    
    
    places = sorted(racers, key = lambda i: int(i[1]))
    

Then print out their names based on the position in the sorted list.

    
    
    print('1st Place: {}'.format(places[0][0]))
    print('2nd Place: {}'.format(places[1][0]))
    print('3rd Place: {}'.format(places[2][0]))
    

