V8.3.6 - acknowledge the most recent 3 alarms script

I'm using this script in a button to acknowledge all alarms. What do I need to add to it so it will acknowledge only the most recent 3 alarms?

    ids = [str(event.id) for event in system.alarm.queryStatus(state=["ActiveUnacked", "ClearUnacked"])]
    system.alarm.acknowledge(ids,'', "admin")

much appreciated

You are providing a list of ids to the acknowledge() function, so if you only want the first 3, you need a portion, or slice, of the full list. For example

myList = [0,1,2,3,4,5]
print myList[:3] # first three elements

>>> 
[0, 1, 2]