I am quite new in programming scene. I was having a hard time grasping the very nature of this code.
import time
from random import randint
replies =["Yes","No","Possibly", "Ask again later", "IDK"]
def question():
print "What is your question?"
question = raw_input()
print "Thinking"
time.sleep(3)
print replies[randint(0,4)]
end()
def end():
print "Thanks for playing! Do you want to try again?"
user_reply = raw_input()
if user_reply == "yes":
question()
print "Welcome to the magic 8-ball"
question()
My questions are:
- As you can see the end() function was called inside the question() function. And suppose that i keep playing the game. What happens to previous caller especially the very first question()? Is it still open? or is it closed once it called end() function.
- Would that build up memories as long as i keep playing the game? I know that the memories are cleared up once the functions end, but in this code it just keeps calling a function. The only time it ends is if you close the program.
Thank you.