One of your friends has compiled a regexp pattern to match all days of the months in the following format: DD/MM/YYYY.
At first glance, the pattern looks fine. However, during matching, the output is always None. Can you spot the mistake?
Regexp flags in Python
Where is a mistake?
Report a typo
Sample Input 1:
10/10/2000Sample Output 1:
<re.Match object; span=(0, 10), match='10/10/2000'>Write a program in Python 3
import re
string = input()
dates = re.compile('''^(0[1-9]|[12][0-9]|3[01]) # digits from 01 to 31
(/) # forward slash
(0[1-9]|1[012]) # digits from 01 to 12
(/) # forward slash
(19|20)\d\d$ # 19 or 20 with any two digits
''')
result = dates.match(string)
print(result)
___
By continuing, you agree to the JetBrains Academy Terms of Service as well as Hyperskill Terms of Service and Privacy Policy.
Create a free account to access the full topic
By continuing, you agree to the JetBrains Academy Terms of Service as well as Hyperskill Terms of Service and Privacy Policy.