Return error to user if user enter wrong option in Python Tree : <p>i am totally new in Python, i try to do a simple code whereby if the user entered a wrong Product code, he will get an "error message" and he will be prompted to enter again. But i just cannot get it to work. Can somebody help. Thanks</p>

<pre><code>class Node(object):
    def __init__(self,val,key,Number):
        self.val = val
        self.key = key
        self.number = Number
        self.left = None
        self.right = None

def search(value,p):
    if(p.val == value):
        print("You bought item:",p.val,",description:", p.key,"cost:", p.number)
        return 1
    else:
        if(p.val !=None):
            if(p.val &lt; value):
                search (value,p.right)
            if(p.val &gt; value):
                search (value,p.left)
        else:
            print("You've entered a wrong option")

root = Node(3,"Chips", "$12" )
root.left = Node(1,"Chicken", "$13")
root.left.right = Node(2,"Potato","$14")
root.right = Node(5,"AisKrim","$15")
root.right.left = Node(4,"Bag","$16")
root.right.right = Node(6,"TV","$17")

option = int(input("Please enter code:"))
answer = search(option,root)

while (answer != 1):
    print("You've entered a wrong option")
    option = int(input("Please enter code:"))
    answer = search(option,root)
</code></pre>
