-1

I wrote this code to test dates but I keep getting this error:

IndentationError: expected an indented block.

I searched for an answer but I couldn't find anything.

def dateIsBefore(y1,m1,d1,y2,m2,d2):
if y1<y2:
    return True
if y1 == y2:
    if m1< m2:
        return True
    if m1 == m2:
        return d1>d2
return False            

def georgiana(y1,m1,d1):
if y1==1582:
    if m1==10:
        if d1>=15:
            return True
        if m1>10:
            return True         
if y1>1582:
    return True 
return False

def Real(y1,m1,d1,y2,m2,d2):
if d1 <= daysOfMonths[m1-1] and d2 <= daysOfMonths[m2-1] and m1 <= 12 and m2 <= 12:
    return True
else:
    return False

def test_dates(y1,m1,d1,y2,m2,d2):
if dateIsBefore(y1,m1,d1,y2,m2,d2) and georgiana(y1,m1,d1,y2,m2,d2) and real(y1,m1,d1,y2,m2,d2) :
    return True
else:   
    return False

print test_dates(2001,8,28,2018,3,16)
  • you have to indent the contents of function `->` . They can't start on the same vertical column as the function declaration. Get an IDE or a smart editor and run auto-indent – Srini Mar 16 '18 at 21:22

1 Answers1

0

Every line that belongs to a function should have its indentation level incremented by one.

So here is what your indentation should look like:

def dateIsBefore(y1, m1, d1, y2, m2, d2):
    if y1 < y2:
        return True
    if y1 == y2:
        if m1 < m2:
            return True
        if m1 == m2:
            return d1 > d2
    return False            

def georgiana(y1, m1, d1):
    if y1 == 1582:
        if m1 == 10:
            if d1 >= 15:
                return True
            if m1 > 10:
                return True         
    if y1 > 1582:
        return True 
    return False

def Real(y1, m1, d1, y2, m2, d2):
    if d1 <= daysOfMonths[m1 - 1] and d2 <= daysOfMonths[m2 - 1] and m1 <= 12 and m2 <= 12:
        return True
    else:
        return False

def test_dates(y1, m1, d1, y2, m2, d2):
    if dateIsBefore(y1, m1, d1, y2, m2, d2) and georgiana(y1, m1, d1, y2, m2, d2) and real(y1, m1, d1, y2, m2, d2):
        return True
    else:   
        return False

print test_dates(2001, 8, 28, 2018, 3, 16)

There are some other problems in your code:

  • You are defining the georgiana() function with 3 arguments: georgiana(y1, m1, d1). But you're calling it with 6 arguments: georgiana(y1, m1, d1, y2, m2, d2).
  • You're defining Real() but calling real().
Ronan Boiteau
  • 9,608
  • 6
  • 34
  • 56