title: How To Remove random string name in my List and Print the the name Removed?
body: <p>I have tried many hours here my code snippet
  when i run the code it only remove the index I want to remove the name and print the name removed</p>
  <pre><code>using System.Collections;
  using System.Collections.Generic;
  using UnityEngine;
  
  public class Player : MonoBehaviour
  {
      public List&lt;string&gt; names = new List&lt;string&gt;();
  
      void Start()
      {
          foreach (var name in names)
          {
              Debug.Log(name);
          }
      }
  
      // Update is called once per frame
      void Update()
      {
  
          if (Input.GetKeyDown(KeyCode.Space))
          {
              int index = Random.Range(0, names.Count);
              names.Remove(names[index]);
              Debug.Log(&quot;Removed: &quot; + names[index]);
          }
      }
  
  }
  </code></pre>