In Python you cannot be ambiguous about it. Either you have
if (x > 0):
if (y > 0):
print "hello"
else:
print "world"
or
if (x > 0)
if (y > 0)
print "hello"
else:
print "world"
The indentation shows which "if" matches the "else". [Note: try as I might, I can't get the "else" in the first example to line up correctly under the first "if".]
In all the languages I have seen that allow this particular ambiguity, the "else" matches with the most recent "if". That may not be true of all languages that ever existed. Usually the easiest thing to do when writing the parser is to match up the "else" with the nearest "if" on the stack.
A similar question: What is the result of 5 - 2 + 1? Is it 4 or 2? Personally I always use parentheses when I write (x - y) + z or x - (y + z) because I can never remember which way the parser will go.