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])
Sort the results using the
sorted() function. Use the example above to help you.
Use a for loop to print the first 5 items. Use the example above to help you.
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.