Python. figuring out how to input a correct phone number
<p>So I'm new to python and I'm writing a program that accepts a phone number in the format XXX-XXX-XXXX and changes any letters to their corresponding numbers.  I need to check the entry and make sure it's in the correct format, and if its not, allow it to be reentered.  I'm having a hard time getting it to prompt me for a new number, and even when that works sometimes, it will still translate the original, wrong phone number.</p>

<p>This is my code so far:</p>

<pre><code>def main():
    phone_number= input('Please enter a phone number in the format XXX-XXX-XXXX: ')
    validNumber(phone_number)
    translateNumber(phone_number)

def validNumber(phone_number):
    for i,c in enumerate(phone_number):
        if i in [3,7]:
            if c != '-':
                phone_number=input('Please enter a valid phone number: ')
            return False
        elif not c.isalnum():
            phone_number=input('Please enter a valid phone number: ')
        return False
    return True

def translateNumber(phone_number):
    s=""
    for char in phone_number:
        if char is '1':
            x1='1'
            s= s + x1
       elif char is '-':
            x2='-'
            s= s + x2
       elif char in 'ABCabc':
           x3='2'
           s= s + x3
</code></pre>

<p>.....etc this part isn't important</p>
