I'm trying to work out how to populate a field depending on the lowest score across 6 other fields. I've read several other questions relating to if/else statements but I'm only just starting to learn Python so I'm struggling to put together any code that works.
I'm trying to populate a 'Main Failing' field, where for each object ID in the feature class the worst scored field out of 6 other fields will be noted.
The other fields are: 'Interconnectivity', 'PropCover', 'PatchSize', 'ShapeIndex', 'Naturalness' and 'EdgeNat' and they are all short integer, with high numbers being better than low numbers.
So for example if 'Interconnectivity' had the lowest score across the 5 fields for one objectID, I would like to work out how to populate the 'Main Failing' column for that objectID with text saying 'Interconnectivity'.
Edited: Here's an example of the code I've tried so far with Branco's help. It's running without errors but is either leaving the MainFailing field blank (if 'return resultList') or is populating it with 0's (if return resultList).
myFunction( !InterconnectivityScore!, !PropCoverScore!, !PatchSizeScore!, !ShapeIndexScore!, !NatScore!, !EdgeNatScore!)
Pre-logic script code:
def myFunction ( interconnectivityScoreValue, propCoverScoreValue, patchSizeScoreValue, shapeIndexScoreValue, natScoreValue, edgeNatScoreValue): resultList = ["",0] if interconnectivityScoreValue <= resultList: resultList = "Interconnectivity" resultList = InterconnectivityScore if propCoverScoreValue <= resultList: resultList = "ProportionalCover" resultList = PropCoverScore if patchSizeScoreValue <= resultList: resultList = "PatchSize" resultList = PatchSizeScore if shapeIndexScoreValue <= resultList: resultList = "ShapeIndex" resultList = ShapeIndexScore if natScoreValue <= resultList: resultList = "Naturalness" resultList = NatScore if edgeNatScoreValue <= resultList: resultList = "EdgeNaturalness" resultList = EdgeNatScore return resultList