my idle can play at first but when a walk a bit my character the walk animation is not stopping,my idle can play at first but when my character stops walking the walk animation is keep playing why?

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class PlayerMovement : MonoBehaviour
{

public Rigidbody2D rb;

public float speed;

public Animator animator;

bool walk = false;

void Start()
{
    walk = false;
}



// Update is called once per frame
void Update()
{

    if(Input.touchCount == 1)
    {
        
        Touch touch = Input.GetTouch(0);
        if(touch.position.x > (Screen.width / 2))
        {
            rb.velocity = new Vector2(speed, 0);
            walk = true;
        }else if(touch.position.x < (Screen.width / 2))
        {
            rb.velocity = new Vector2(-speed, 0);
            walk = true;
        }

        if(walk == true)
        {
            animator.SetBool("Walk", true);
            Debug.Log("moving");
        }

        if(walk == false)
        {
            animator.SetBool("Walk", false);
            Debug.Log("not movingggg");
        }

        

    }    
}

}
,

Did you path(direct) your walk animation to the idle after stopping it?