How to randomize a scene changer without replaying the current scene?

So my idea is to create a scene changer that randomizes which scene will be played whenever a level is completed. However I want to make sure that the next scene being randomized is not the current scene.

Here is what I did in my “wait” method (sceneName is a variable containing the name of the current scene):

Enumerator Wait()
    {
        if (sceneName == "A")
        {
            yield return new WaitForSeconds(2.0f);
            SceneManager.LoadScene("Game", LoadSceneMode.Single);
        }

        else if(sceneName == "Ran1"){
            yield return new WaitForSeconds(2.0f);

            string[] zones = new string[2] {"Ran2", "Ran3" };
            int random = Random.Range(0, 2);
            Application.LoadLevel(zones[random]);

        }

        else if (sceneName == "Ran2")
        {
            yield return new WaitForSeconds(2.0f);

            string[] zones = new string[2] { "Ran1", "Ran3" };
            int random = Random.Range(0, 2);
            Application.LoadLevel(zones[random]);

        }

        else if (sceneName == "Ran3")
        {
            yield return new WaitForSeconds(2.0f);

            string[] zones = new string[2] { "Ran1", "Ran2" };
            int random = Random.Range(0, 2);
            Application.LoadLevel(zones[random]);

        }
        else
        {
            yield return new WaitForSeconds(2.0f);

            string[] zones = new string[3] { "Ran1", "Ran2", "Ran3" };
            int random = Random.Range(0, 3);
            Application.LoadLevel(zones[random]);
        }
        
    }

It technically works, but it doesn’t seem to be very dynamic.

How can I revise this to not use a bunch of if statements?

You only need one if statement for this. Define a list containing the names of all your levels you want to be randomly selected and then remove the one equaling the current scene name.

for instance,

List<string> allScenes = new List<string>(){"scene1", "scene2", etc};

IEnumeratorLoadRandomLevel(string currentLevelName)
{
    if (scenename == "A")
    {
        yield return new WaitForSeconds(2f);
       Application.LoadScene("Game");
    }
    else
    {
        allScenes.Remove(currentLevelName);
        yield return new WaitForSeconds(2f);
       Application.LoadScene(allScenes[Random.Range(0, allScenes.Count)]);
    }
}