abaqus scripting-for loop+if

hi, 

i am trying to write if loop inside for loop as follows.

a=0

for p in range(a,9):

print "p in main loop = ", p

print a

if p >5:

print "p in second loop= ", p

a=9

i expect that when p becomes 6, main for loop would be stopped. but unexpectedly for loop continues without considering value of a. why this happens. what is the method to stop for loop when p=6