I am using Python 3 in ArcGIS Pro. In plain English, my goal is calculate one field in a table using a list of values from another field. I can do this with a long list of if statements, but I can't figure out the syntax to do it with lists (and maybe for loops?).
For example, let's say I have two lists:
veg = ['Carrot', 'Celery', 'Broccoli']
fruit = ['Apple', 'Banana', 'Grape']
I would essentially like to ask..."If the field contains a value from the list 'veg', return 'Vegetable', else if the field contains a value from list 'fruit', return 'Fruit', else leave null"
I know this is possible I am just having trouble with the syntax. I would like to avoid doing this ad nauseum:
if FIELD == 'Carrot':
return 'Vegetable
elif FIELD == 'Celery':
return 'Vegetable'
I know it's possible I am just struggling with the syntax. I am reducing ~40 values in one field to 2 values in another.