How to spawn a prefab randomly only once

I’m working on a small game, where the player has to find their home. Ideally the house would spawn at a new location every time the game is played. I am new to coding so I’m not sure if what I have made works/ make sense. So far I added a condition to check if the house(right now just a cube) is in the game. However I have no idea if it is working. Without the condition the cube does keep spawning. I am also having trouble spawning the cube in a different location each time. It shows up in the same spot no matter what.

200147-my-pink-world-prototype-pc-mac-linux-standalone-un.png
This is what happens without the condition.

Code below:

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

public class RandomPlacement : MonoBehaviour
{
    public GameObject cubePrefab;

    void Update()
    {
        if (cubePrefab ==true) {
            Spawn();
        }
        void Spawn()
        {
            Vector3 randomSpawnPosition = new Vector3(Random.Range(0, 11), 50, Random.Range(0, 11));
            Instantiate(cubePrefab, randomSpawnPosition, Quaternion.identity);
        }
    }
}

First of all, if you want to only spawn the house once, you might want to put your code in Start() instead of update() which repeats the code every frame. You also should define the Spawn() function outside.

 public class RandomPlacement : MonoBehaviour
 {
     public GameObject cubePrefab;
 
    void Start() {
         Spawn();
     }

     void Update()
     {

     }
    
     void Spawn()
     {
             Vector3 randomSpawnPosition = new Vector3(Random.Range(0, 11), 50, Random.Range(0, 11));
             Instantiate(cubePrefab, randomSpawnPosition, Quaternion.identity);
     }

 }