Python: How to check user input is a value or a str?
<p>how to write python code to ask user to input a number, return the int of the number, and if user input a str, for example "One", return a error message like "please input a int number"? How could I do that?</p>

<p>Also I have to check if the number is odd or not, so i m not sure if I can do it with try and except.I dunno how to add that in my code.</p>

<p>Thanks.</p>

<pre><code>def getnum(): 

    errormessage="Please input a odd number"

    asknum=raw_input("Please input a number: ")
    num=int(asknum)

    if num%2!=0:  #return num if it is odd number
        print num

    else:
        print errormessage
        return getnum()

getnum()
</code></pre>
