Using python to interact with the operating System week 3-Advanced Reg expr practice quiz | Coursera Community
Coursera Header

Using python to interact with the operating System week 3-Advanced Reg expr practice quiz

  • 17 July 2020
  • 1 reply
  • 51 views

Badge +1

any one pls solve my problem..

  1. Iam in week3(Adavanced Regular Expressions)
  2. All concepts are very Interesting and in practice quiz i had a problem
  3. At last question in practice quiz(i mean 5th question) all outputs are crct but even though i got 0 by showing some error
  4. Error is “””Not quite. How did you define the capturing groups that are used to change the format of the passed text? Did you remember the escape characters for digits and word boundaries?”””
  5. And even I got passed but I need to know Where I did mistake because it’s a important concept so pls solve my issue.
  6. Here by Iam attaching my pattern as txt..
  7. re.sub(r'(\b\d{3}\b)(-\b\d{3}\b-\b\d{4}\b)',r'(\1)\2',phone)


1 reply

Badge

try this…

result = re.sub(r"\b(\d{3})-(\d{3})-(\d{4})\b",r"(\1) \2-\3",phone)

Reply