The Watch section evaluates expressions you choose to monitor while the debugger pauses during execution. Add an expression with the plus sign, then inspect its changing result alongside variables and the call stack. section 8.2.2
Monitoring a word-matching condition
While debugging count_words, add "dan" in word.lower() to the Watch section. The debugger shows whether the expression is True or False for each value of word, helping you follow the function’s behavior. section 8.2.2
Listing 8.4 Incorrect count_words function for debugging
def count_words(words):
count = 0
for word in words:
if "dan" in word.lower():
count += 1
return count
words = ["Dan", "danger", "Leo"] #1
print(count_words(words)) #1
Inspect the count_words example while using a breakpoint and watched expression to follow its execution. section 8.2.2
