Executing code after a coroutine, but not within the coroutine

Say I have the following the code

int i = 0;

void Start()
{
    StartCoroutine("Code");
    Code2();
}

IENumerator Code()
{
    yield return new WaitForSeconds(1.0f);
    i = 2;
}

void Code2()
{
    print(i);
}

Obviously i is going to print 0, because the code executes Code2 before reaching i = 2. How could I make it print 2 without putting Code2() after the yield return?

  1. Change Start() to return an IEnumerator instead of void.

  2. Start and yield the “Code” coroutine inside of the Start().

    int i = 0;
    
    
    IEnumerator Start()
    {
    	yield return StartCoroutine("Code");
    	Code2();
    }
     
    IEnumerator Code()
    {
    	yield return new WaitForSeconds(1.0f);
     	i = 2;
    }
     
    void Code2()
    {
    	print(i);
    }