Common numbers

Report a typo

Imagine you're a math and physics teacher at school. You want to keep the students who have taken both courses on a new list. To achieve this, correct the shuffled function below.

The following function takes two lists as parameters. It compares the items in math_students with the items in physic_students. Finally, it adds the common values to a new list and returns it.

Reorder lines using drag or arrows. Adjust indentation with left buttons
                return common_students
              
                for i in math_students:
              
                common_students.append(i)
              
                common_students = []
              
                if i in physic_students and i not in common_students:
              
                def check_membership(math_students, physic_students):
              
___

Create a free account to access the full topic