Why won't this character rotate?

Hi, I have a 3rd person character who I want to make look around when the user hits WASD keys. I have some code for it, and the rotations don’t work. Can anyone see any problems?
Thanks.

using System.Collections;

public class Move : MonoBehaviour {

    public Animator anim;

    private float rot;
   
    void Start () {
        anim = this.gameObject.GetComponent<Animator> ();
        anim.Play ("Idle");
    }

    void Update () {
        string s = null;
        bool move = false;
        if (Input.GetKey (KeyCode.W)) {
            move = true;
            s = "Walk";
        }
        if (Input.GetKey (KeyCode.A)) {
            s = "Walk";
            move = true;
        }
        if (Input.GetKey (KeyCode.S)) {
            s = "Walk";
            move = true;
        }
        if (Input.GetKey (KeyCode.D)) {
            s = "Walk";
            move = true;
        }

        if (Input.GetKeyDown (KeyCode.W)) {
            rot = 0;
        }
        if (Input.GetKeyDown (KeyCode.A)) {
            rot = 270;
        }
        if (Input.GetKeyDown (KeyCode.D)) {
            rot = 90;
        }
        if (Input.GetKeyDown (KeyCode.S)) {
            rot = 180;
        }

        if (s == null) {
            s = "Idle";
        }
        Quaternion rotation = this.gameObject.transform.rotation;
        this.gameObject.transform.rotation = new Quaternion (rotation.x, rot, rotation.z, rotation.w);   
        anim.Play (s);
    }
}

My guess is that it is because you create a new Quaternion, which is highly discouraged unless you know what you are doing.

Check out the documentation for Quaternions: Unity - Scripting API:

I think you want to use Quaternion.Set in your case, or Quaternion.RotateTowards if you want to rotate over time.