How can i make this animation play only once? C#

Sorry to ask another question but I am a little stuck again… How can I make the On and Off animations in this flashlight script play only once? I know why it loops but I don’t know how to make it stop, doesn’t matter how. Thanks in advance.

using UnityEngine;
using System.Collections;

public class Flashlight : MonoBehaviour {
	
	public GameObject Player;
	Light flashlight;
	bool on = false;

	// Use this for initialization
	void Start () {
		flashlight = GetComponentInChildren<Light>();
	}
	
	// Update is called once per frame
	void Update () {
		Debug.Log(on);

		// OnOff
		if(on){
			animation.Play("On"); // Make this play once
			flashlight.light.enabled = true;
		else if(!on)
			animation.Play("Off"); // Make this play once
			flashlight.light.enabled = false;

		if(Input.GetButtonDown("Flashlight")){
		   on = !on;
		}

	}
}

Have you tried this: