The Call Stack section in the VS Code debugger lists the functions that were called to reach the current line of code. It shows where execution is nested, helping you connect the highlighted line with the function that is running. section 8.2.2
Tracing count_words
When execution pauses inside count_words, the Call Stack shows <module> calling count_words. The editor highlights the current line inside count_words, such as count = 0, so you can compare the call chain with the paused code. 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 the Call Stack to follow the transition from the module-level call into the function. section 8.2.2
