0

Why my code dont print Valid

import re #your code goes here c="^(1,8,9)?\d{7}

quot; a=r"c" if re.match(a,c): print("Valid") else: print("Invalid")

16th May 2022, 4:51 PM
Reza Jaferyan
Reza Jaferyan - avatar
1 Antwort
0
You are comparing string c on pattern a but you have pattern in 'c', string in 'a' Should be like re.match(c, a) But you're pattern search the string starts with 1,8,9 (camma is also a character, not a delimiter, use | instead ) and ends with more 7 digits. Your string has only single character 'c' so it's output invalid anyways.. take input into variable a. Hope it helps...
16th May 2022, 5:06 PM
Jayakrishna 🇮🇳