Consider the following program.
test = "whee"
check = "e"
answer = helper(test, check)
print("the answer is %d" % (answer))
def helper(word, letter):
print("word: %s" % (word))
print("letter: %s" % (letter))
x = 0
for ch in word:
if ch == letter:
x = x+1
# draw stack here, just before return
- Draw the call stack as it would look just prior to returning from helper.
- What is the program's output (i.e. what does it print when the program is run)?
- What does the helper function compute?
- What would helper("moobaalalala", "a") return?
- What would helper("zoo", "a") return?