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