if animation is finished do the following

how to make a script that will check if an animation is finished?
i know that the following script isn0t working but is it possible to do something like that?

function Update () {
	if(Input.GetButtonDown("sprint")){
		animation.Play("sprintStart");
	}
	if(animation.finished("sprintStart")){
		animation.Play("sprint");
	}
}

You can get the length of an animation clip in seconds, so you could build your own logic around that or, for example, if done in a couroutine, you could suspend the coroutine execution for the length of the animation.

yield WaitForSeconds (animation.clip.length);

Have you tried something like this?