Question: Python programming. Please provide the code and resulting output Question You are given a list of characters in Harry Potter. Imagine you are Minerva McGonagall,
Python programming. Please provide the code and resulting output
Question You are given a list of characters in Harry Potter. Imagine you are Minerva McGonagall, and you need to pick the students from your own house, which is Gryffindor, from the list. To do so ...
- THIS MUST BE DONE IN ONE LINE - First, remove the duplicate names in the list provided - Then, remove the students that are not in Gryffindor - Finally, sort the list of students by their first name - Don't forget to return the resulting list of names!
Args: character_list (list) Returns: list
>>> character_gryffindor(["Scorpius Malfoy, Slytherin", "Harry Potter, Gryffindor", "Cedric Diggory, Hufflepuff", "Ronald Weasley, Gryffindor", "Luna Lovegood, Ravenclaw"]) ['Harry Potter, Gryffindor', 'Ronald Weasley, Gryffindor']
>>> character_gryffindor(["Hermione Granger, Gryffindor", "Hermione Granger, Gryffindor", "Cedric Diggory, Hufflepuff", "Sirius Black, Gryffindor", "James Potter, Gryffindor"]) ['Hermione Granger, Gryffindor', 'James Potter, Gryffindor', 'Sirius Black, Gryffindor']
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
