import sys var =gp.GetParameterAsText(0) if var not in ("cat","dog","mouse"): print "ERROR: You entered the wrong animal! Exiting script..."; sys.exit() else: print var + " is a valid entry. Good job!"
if animal == "dog": pass #aka don't do anything else: print "not a dog"
for x in (1,2,3,4,5): if x > 4: break #aka stop looping else: print x
This did not work for me. I had a loop running a selection and writing values to a text file and cancel would only effectively cancel the current selection. I tried cancel about 10 times before calling it quits. One thing that will always work is "End Process" in the task manager but that is probably not recommended.