# Stage 4 # A function that asks the user to enter a positive whole number # (positive integer) and returns it (if it is positive, otherwise, # the function makes the user enter another number). # This function returns an integer. def getPositiveInt(): while (True): userInput = raw_input("Enter a positive integer:") try: userInt = int( userInput) if ( userInt > 0 ): return( userInt) else: print "Number is NOT positive! Try again!" except: print "Not an integer! Try again!" # Stage 3 # A function that asks the user to enter a positive whole number # (positive integer) and returns it (if it is positive, otherwise, # the function makes the user enter another number). # This function returns an integer. ##def getPositiveInt(): ## while (True): ## userInput = raw_input("Enter a positive integer:") ## ## try: ## userInt = int( userInput) ## ## if ( userInt > 0 ): ## return( userInt) ## else: ## print "Number is NOT positive! Try again!" ## ## ## except: ## print "Not an integer! Try again!" # Stage 2 # A function that asks the user to enter a positive whole number # (positive integer) and returns it (if it is positive, otherwise, # the function makes the user enter another number). # This function returns an integer. ##def getPositiveInt(): ## while (True): ## userInput = raw_input("Enter a positive integer:") ## userInt = int( userInput) ## ## if ( userInt > 0 ): ## return( userInt) ## else: ## print "Number is NOT positive! Try again!" ## ## ## # Stage 1: # # A function that asks the user to enter a positive whole number # (positive integer) and returns it. # This function returns an integer. #def getPositiveInt(): # userInput = raw_input("Enter a positive integer:") # userInt = int( userInput) # return( userInt)