A nested loop places one loop inside another. The outer loop handles each larger item; the inner loop examines the smaller items belonging to it. In the Scrabble word-matching problem, the outer loop checks each valid word, while the inner loop checks each letter in that word. section 19.1 section 19.2
Checking words against tiles
For each word, begin with all available tiles. Check its letters one at a time. If a letter is missing, stop checking that word and continue with the next one. If a letter is found, remove it from the remaining tiles so repeated letters are handled correctly. After the inner loop, add the word only if every letter was matched. section 19.2
for word in valid_words:
for letter in word:
if letter not in tiles:
stop looking at remaining letters and go to next word
else:
remove letter from tiles (in case of duplicates)
if all letters in valid word found in tiles:
add word to found_words
Trace the outer word loop and inner letter loop directly, including the early exit for a missing letter and the handling of duplicate tiles. section 19.1 section 19.2


