Exercise 6: Find the First Duplicate, Then Stop — Possible Solution ==================================================================== ids = [101, 205, 309, 205, 412, 309] index = 0 first_duplicate = None while index < len(ids) and first_duplicate is None: current = ids[index] check_index = 0 while check_index < index: if ids[check_index] == current: first_duplicate = current break check_index += 1 index += 1 if first_duplicate is None: print("No duplicates found") else: print(f"First duplicate: {first_duplicate}") Output: First duplicate: 205 WHY THIS WORKS AS AN ANSWER ------------------------------ The inner loop only ever checks positions BEFORE the current one (check_index < index, not < len(ids)) — this is what makes 205 the answer rather than 309: the second 205 (at index 3) is confirmed as a repeat of an earlier value before the second 309 (at index 5) is ever reached, because the outer loop processes ids in order. Stopping "immediately" needs two things, not one: the inner break exits the inner search the moment a match is found, but the outer while's own condition, "and first_duplicate is None", is what stops the OUTER loop from moving on to check any later elements at all once an answer has been found. Without that second condition, the outer loop would keep walking to the end of the list even after first_duplicate was already set — break alone only ever escapes the loop it's physically written inside.