Great idea @bitshift-r ! Here, let me simply it further.
for action in ["object_zero", "object_one", "object_two", "object_three"]:
if event.is_action_pressed(action):
object = i
break
Edit: oops! I forgot about the i
variable. Looks like your original function will have to do for now. :/