Preserve groups while selecting scores

A teacher stores quiz scores out of 10 in a Python nested list, with one inner list per study group. The program below creates a new nested list containing only scores of at least 6.


Python
scores = [[4, 9, 2], [], [7, 5], [3, 5], [8]]
selected = []

for row in scores:
    kept = []
    for score in row:
        if score >= 6:
            kept.append(score)
    selected.append(kept)


After the program finishes, determine the number of inner lists in selected, the number of empty inner lists in selected, and the total number of retained scores across all its inner lists. Report each as an exact integer count.

Your answers

Create a free account to get started

Unlock full course notes by signing up

  • Video lessons taught by top educators
  • Practice questions with guided solutions
  • Written review notes for reference
  • Expert answers anytime from course tutors

More Nested Lists Questions: