-2

Where was I wrong?

import re

def check_num(input):
    pattern = re.compile(r"\bd{3}\d{3}-\d{4}\b")
    match = pattern.search(input)
    if match:
        return print(match.group)
    return print("None")
    print(check_num("my number is 817 994-8667"))

compiler doesnt return anything what should i do now??

James
  • 32,991
  • 4
  • 47
  • 70
  • Does return print() work? Why dont just print or return? Or this does both? – Charis Moutafidis Apr 21 '18 at 01:36
  • Not enough information. How are you calling your function? Are you passing a string that you know matches the regex pattern? Please read [mcve] – wwii Apr 21 '18 at 01:39
  • The only place you're calling your function is within the function itself—it will never run. Outdent your last line by four spaces to bring it out of the function body. Also, just do one of `return` or `print`, as Charis suggests. – ChrisGPT was on strike Apr 21 '18 at 02:03

1 Answers1

-1

If you are running plain python script, you need to add following code to bottom of file,

if __name__ == '__name__':
    check_num(number)

or

just add,

check_num(number)
Nishant Nawarkhede
  • 8,234
  • 12
  • 59
  • 81