Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
in Python by (19.9k points)

I am trying to execute the following python code:

def example(p,q):

a = p.find(" ")

b = q.find(" ")

str_p = p[0:a]

str_q = p[b+1:]

if str_p == str_q:

    result = True

else:

    result = False

return result

And I get the following error:

IndentationError: expected an indented block

1 Answer

0 votes
by (25.1k points)

This is because your code is not properly indented. It should be like this:

def example(p,q):

    a = p.find(" ")

    b = q.find(" ")

    str_p = p[0:a]

    str_q = p[b+1:]

    if str_p == str_q:

        result = True

    else:

        result = False

    return result

If you want to get a deeper understanding of python you can watch this youtube video: 

Browse Categories

...