Consider the following program.
def main():
print("in main")
test = "whee"
check = "e"
answer = helper(test, check)
print("the answer is %d" % (answer))
def helper(word, letter):
print("in helper")
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
return x
main()
- 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?