The code is using a for-else clause, not an if-else clause!
for blah: do stuff else: do more
The do more clause is executed if and only if you exit the for loop normally, i.e. without raising an error or using a break statement.
CLICK HERE to find out more related problems solutions.