I have a simple Python question about how my brains froze. This piece of code works. But when I replace "258 494-3929" with a phone number, I get the following error below:
phone_pattern = '^\d{3} ?\d{3}-\d{4}$'
if re.search(phone_pattern, "258 494-3929"):
print "Pattern matches"
else:
print "Pattern doesn't match!"
Pattern does not match
Please enter a phone number: 258 494-3929
Traceback (most recent call last):
File "pattern_match.py", line 16, in <module>
phoneNumber = str(input("Please enter a phone number: "))
File "<string>", line 1
258 494-3929
^
SyntaxError: invalid syntax
C:\Users\Developer\Documents\PythonDemo>
By the way, I did import reand tried to use rstripin case\n
What else can I lose?
source
share