I think is the general idea you're looking for.def ValidateList(in_list, in_value):
try:
inputList.index(Input_Layer)
return 1
except ValueError:
print ("Input '" + in_value + "' is invalid.")
print ("Input should be one of the following:")
for curItem in inputList:
print curItem
return 0
# Script arguments
Input_Layer = 'Test'
if Input_Layer == '#' or not Input_Layer:
Input_Layer = "Parcels" # provide a default value if unspecified
inputList = ['Parcels', 'RollBoundary']
if ValidateList(inputList, Input_Layer):
print ("Put execution code here.")
Code will only run if the input value matches your specified list; otherwise, it will print the list of valid values to the user.