Hi Rhea,
As everyone else has mentioned, python identifies a new block of code based on indentations.
In this case your, all the lines under your function should be indented. Then only Python can understand that these lines are the body of the function.
Try modifying your code 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
Hope this helps.