Error "There is already a local variable with the name 'obstacle'." How can I make it work?

Hello. This is the part of my script Unity hates. I can't assign "obstacle" more than one time. How can I fix this and let it work? Thank you!

if(whichToSpawn == 0){
    var obstacle = Ob_1;
}
else if(whichToSpawn == 1){
    var obstacle = Ob_1;
}
else if(whichToSpawn == 2){
    var obstacle = Ob_3;
}

Take off the declarations for the other two variables.

you have to create the variable obstacle once :

var obstacle=Ob_1;
    if(whichToSpawn == 0){
     obstacle = Ob_1;
}
else if(whichToSpawn == 1){
     obstacle = Ob_1;
}
else if(whichToSpawn == 2){
     obstacle = Ob_3;
}