You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

1.8 KiB

In [ ]:
class letterLeaf:
    def __init__(self,question):
        self.yes = None
        self.no = None
        self.question = question
In [ ]:
# tree traversals, here to print stuff 
def inorder(treeName):
    if treeName:
        inorder(treeName.yes)
        print(treeName.question)
        inorder(treeName.no)
In [ ]:
# interactive user input utility   
def saysYes(ques):
    while True:
        ans = input(ques)
        ans = ans[0:1].lower()
        if ans == 'y': return True
        else : return False