Animation,God!

I am new in Unity. Learn it for 2 weeks. I am sorry about my English, I am still learning. So…
Please someone tell me how to switch animation for my character when I pressed buttons(WASD or another, just for some action). I am creating third person game. I have watched lots of videos about animation controller. I made all things what they has shown and told me, but it do NOT work.
Example code what I have written:

void Update(){
if(Input.GetKey(“w”)){anim.Play(“WALK”);}
or
float h = Input.getaxis(“Horizontal”);
flaot v = Input.getaxis(“Vertical”);
//BlendTree was created
anim.SetFloat(“speed”,true);// 0 is walkstate,1 is runstate
}
first option work but not clear. I have some fast leaps.
Please, if you can, just give working code or explain how I can fix it or explain how I can find information for selfhelp. Notes: when I pressed some button - animation go, released - stop. Oh, it will be nice if IT AUTOPLAYING WHEN COMES TO END!!!NOT JUST STOP AT LAST FRAME AS STATUE!!!
thank you for attention. I hope some understand my pain and can help)))

If you are new you should watch this official Unity training video to learn about animation. It is long but it is worth it.

https://unity3d.com/learn/tutorials/modules/intermediate/live-training-archive/setting-up-a-humanoid-avatar

Beginner Tip: Always use unity live trainings or tutorials from unity site to learn something new in Unity, if it does not help then go for other tutorials.