0ding ?roblem 4.3.3 (Cx er n al resource) (3.0 points possible) Moviesales.py Su
ID: 3704169 • Letter: 0
Question
0ding ?roblem 4.3.3 (Cx er n al resource) (3.0 points possible) Moviesales.py Submit Run Grades Reset 1 #Write a function called find max sales. find max sales will 2 #have one parameter: a list of tuples. Each tuple-in the 3 #list will have two items: a string and an integer. The 4 #string will 5 #will represent that movie's total ticket sales (in 6 #of dollars) represent the name of a movic, and the inte 8 #The function should return the movie from the list that 9 #had the most sales. Return only the movie name, not the 10 #full tuple 12 13 #Write your function here! 14 def max sales(tuples) 15 16 17 18 #Below are some lines of code that will test your function 19 #You can change the value of the variable(s) to test your 29 #function with different inputs 21# 22 #If your function ?0rks correctly, this will originally 23 #print: Rogue One 24 movie_list - [C"Finding Dory", 486), ("Captain America: Civil War 408), ("Deadpool", 363), ("Zootopia", 341), "Rogue One", 529), ("The Secret Life of PetsBatman vSuperman, 330), "Sing", 268), uicide Squad", 325Theungle Book,364) s print(find max sles movie list)) 26 27 28 29 30 Console output will be displayed hereExplanation / Answer
def find_max_sales(lst): max_sales = 0 best_name = '' for name, sales in lst: if sales > max_sales: best_name = name max_sales = sales return best_name
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.