I'm new to Python and I'm trying to create a script which adds fields to a feature class. The provided script is running well, but I want to create an additional parameter, which asks for the required field length of the fields to be created. The field length is only important if the field type "TEXT" is selected. The script should only take the additional parameter into account if the user selects "TEXT" under the field type. I think I need to put an if...else statement, but I don't know how do that.
import arcpy # input data set (feature class, shapefile) inputFC = arcpy.GetParameterAsText(0) # list of field names inputString =arcpy.GetParameterAsText(1) fieldList =inputString.split(";") fieldType = arcpy.GetParameterAsText(2) for name in fieldList: arcpy.AddField_management(inputFC , name, fieldType) arcpy.AddMessage ("field created: " + name) arcpy.AddMessage ("Calculation complete")