Learn

Finally, to view the results, we’ll have to sort them and then display the top 5 traits from the sorted results.

These will be the top 5 traits you share with the celebrity you selected for the application.

sorted_result = sorted(compared_results.items(), key=operator.itemgetter(1)) for keys, value in sorted_result[:5]: print keys, print(user[keys]), print ('->'), print (celebrity[keys]), print ('->'), print (compared_results[keys])

Instructions

1.

Sort the results using the sorted() function. Use the example above to help you.

2.

Use a for loop to print the first 5 items. Use the example above to help you.

3.

Click Run to run your code and see the results!

Note: If the terminal is outputting indentation error notices, double check to make sure that your code follows the proper Python indentation practices.

Take this course for free

Mini Info Outline Icon
By signing up for Codecademy, you agree to Codecademy's Terms of Service & Privacy Policy.

Or sign up using:

Already have an account?