Error with if else statements that can't be fixed

I know how local variables are only reachable depending on the scope it’s in, but what I meant is that the if else statement contains 2 different scopes within the function and that’s what’s causing the original error? Such that we don’t need to use returning to use a value from the if statement to the else statement?