Help to play animations using gdscript

Godot Version

4.2

Question

Need to set guard animation to play and stop at end while the key is being pressed, and play backwards after the key is released. Whenever i try the animation keep looping. Tried animation.stop() at the end but still repeating. Repeat button on animation player is disabled.

show your code to play and stop

Hi i managed to solve the toggle animations but now i’m facing another problem. How to blend 2 animations to playback at the same time using animation player node?