Restricting the User Input to Alphabets
<p>I'm a technical writer learning python. I wanted to write a program for validating the Name field input,as a practise, restricting the the user entries to alphabets.I saw a similar code for validating number (Age)field here, and adopted it for alphabets as below:</p>

<pre><code>import string
</code></pre>

<p><code>import re</code></p>

<pre><code>r = re.compile(r'[a-zA-Z]+') 
print "WELCOME FOR NAME VERIFICATION. TYPE ALPHABETS ONLY!"
print raw_input("Your Name:")
x = r
if x == r:
    print x
elif x != r:
    print "Come on,'", x,"' can't be your name"
    print raw_input("Your Name:")
if 5&lt;=len(x)&lt;=10:
    print "Hi,", x, "!"
elif len(x)&gt;10:
    print "Mmm,Your name is too long!"
elif len(x)&lt;5:
    print "Alas, your name is too short!"

raw_input("Press 'Enter' to exit!")
</code></pre>

<p>I intend this code block to do two things. Namely, display the input prompt until the user inputs alphabets only as 'Name'. Then, if that happens, process the length of that input and display messages as coded. But, I get two problems that I could not solve even after a lot of attempts. Either, even the correct entries are rejected by exception code or wrong entries are also accepted and their length is processed.  </p>

<p>Please help me to debug my code. And, is it  possible to do it without using the reg exp?</p>
