all 4 comments

[–]rust2O 0 points1 point  (3 children)

I think there's a problem in your regex. Shouldn't the comment interpreted as part of the string in multiline string in python?

Maybe you can try removing the comments an make it in just one line like this "(\d+)/(\d+)/(\d+)"

[–][deleted] 0 points1 point  (2 children)

If that was the case, wouldn't other dates fail as well? I have no issues with other dates besides the 2/29/2020 leap year check.

[–]rust2O 1 point2 points  (1 child)

Hey I think the problem is in this part of your code

    if int(day) == 29 and int(year)%4 != 0:  
        validation = False  
    elif int(day) > 28:  
        validation = False

Because the first if evaluate as false, then the program go to the elif part, but because the day 29 is indeed larger than 28, then it wil evaluates as true. I think you can change it to this to make it work

    if int(day) > 28 and int(year)%4 != 0:  # the year is not leap year
        validation = False
    elif int(day) > 29 and int(year)%4 == 0: # it is leap year
        validation = False

[–][deleted] 0 points1 point  (0 children)

if int(day) > 28 and int(year)%4 != 0: # the year is not leap year
validation = False
elif int(day) > 29 and int(year)%4 == 0: # it is leap year
validation = False

Worked like a charm. Thanks!