What unwritten rule keeps parallel lists in sync — and what breaks the moment you forget to mirror one deletion?
Short drills on what this video just taught. Write the code, run the checks, and reveal the answer only if you are stuck.
Two lists are kept in step by hand — position i in one describes the same student as position i in the other:
names = ['Ana', 'John', 'Denise', 'Katy', 'Omar', 'Priya'] grades = ['B', 'A', 'A', 'B', 'C', 'A']
Look up the grade belonging to the student named in target, and assign to pair a tuple holding that student's name and that grade, in that order.
Do not count the positions off the page yourself — make Python find the position, so that your code would still be right if the roster changed. (Hint: a list's .index() method hands back the position of the first element equal to what you pass it.)
Parallel lists and the shared-index rule
Write names and grade side by side, state the rule that index i holds one student in both, trace get_grade_list('Ana', names, grade) to ('Ana', 'B'), and record what adding or dropping a student costs.
One master list of lists
Write out the grades master list holding eric, ana and john, each a name plus labelled 'ps' and 'mq' sublists, and trace get_grades('eric', 'mq', grades) through both loops.
Data stored against a key
State the idea both attempts share: every score is held against a key, whether that key is a student name or the label 'ps' or 'mq'.