I'm trying to automate a simple repetitive task on QGIS. I have some shapefiles with varying number of features in a layer and about 10 different attributes for each feature. I need to add the same string value ("negative") to one of these attributes, over and over again. Copy, paste works but since I want to sharpen my Python scripting skills I'd like to achieve this by creating a simple Python script.
I'm able to print values of attributes using something like this;
layer = iface.activeLayer()
for feature in layer.getFeatures():
print("{acreage} acres in {name}".format(name=feature['fieldname'],acreage=feature['acreage']))
But I'm stuck at this point. How would I write "negative" to the attribute "acreage"? I tried set.Feature() but it just didn't work.