Obstacle avoiding robot ...randoms

i want the robot…when faces obstacle…turn right or left randomly///…but my code is not working…i am using arduino nano …and l293d ic…here is my code…plz give me corrections…

long randNumber;
const int EchoPin = 8;
const int TriggerPin = 6;
float Duration;
float Distance;

const int LeftMotorICpin1 = 2;
const int LeftMotorICpin2 = 4;
const int RightMotorICpin1 = 7;
const int RightMotorICpin2 = 3; 

//**********************VOID SETUP***************************//
void setup()
{
  Serial.begin(9600);//Serial communication bandwith rate : 9600...if your computers bandwith is diffrent
  //            |_________
  //                      |
  //you can edit it from here**
  pinMode(LeftMotorICpin1, OUTPUT);  // Digital pin 10 set as output Pin
  pinMode(LeftMotorICpin2, OUTPUT);  // Digital pin 11 set as output Pin
  pinMode(RightMotorICpin1, OUTPUT);  // Digital pin 12 set as output Pin
  pinMode(RightMotorICpin2, OUTPUT);  // Digital pin 13 set as output Pin
  pinMode(TriggerPin, OUTPUT);
  pinMode(EchoPin, INPUT);
  randomSeed(analogRead(0));

  
}
//************************VOID lOOP*****************************//
void loop()
{
  digitalWrite(TriggerPin, LOW);
  delay(2);
  digitalWrite(TriggerPin, HIGH);
  delayMicroseconds(10);
  digitalWrite(TriggerPin, LOW);
  Duration = pulseIn(EchoPin, HIGH);
  Distance = (Duration * 0.034) / 2;
  
  randNumber = random(2);
  Serial.println(randNumber);
  delay(50);

  if (Distance >= 40) // Forward
  {
    digitalWrite(LeftMotorICpin1, HIGH);
    digitalWrite(LeftMotorICpin2, LOW);
    digitalWrite(RightMotorICpin1, HIGH);
    digitalWrite(RightMotorICpin2, LOW);
  }
  if ( Distance < 20) // Backward
  {
    digitalWrite(LeftMotorICpin1, LOW);
    digitalWrite(LeftMotorICpin2, HIGH);
    digitalWrite(RightMotorICpin1, LOW);
    digitalWrite(RightMotorICpin2, HIGH);

  }
  if (randNumber = 0 & Distance < 40 & Distance >= 20) //Right
  {
    digitalWrite(LeftMotorICpin1, HIGH);
    digitalWrite(LeftMotorICpin2, LOW);
    digitalWrite(RightMotorICpin1, LOW);
    digitalWrite(RightMotorICpin2, LOW);

  }
  if (randNumber = 1 & Distance < 40 & Distance >= 20) //Left
  {
    digitalWrite(LeftMotorICpin1, LOW);
    digitalWrite(LeftMotorICpin2, LOW);
    digitalWrite(RightMotorICpin1, HIGH);
    digitalWrite(RightMotorICpin2, LOW);

  }
  
  

}

= for assignment,== for comparison.

  if (randNumber = 1 & Distance < 40 & Distance >= 20) //Left

&& is for boolean logic (e.g. combining comparisons), & is for bitwise and’ing of all the bits in a variable.

If you get confused, just use the keyword “and” instead of “&&”.

  if (randNumber == 1 and Distance < 40 and Distance >= 20) //Left

The main reason it matters, is because of operator precedence.

but now...everything is working fine...but my robot cant turn neither left nor right...i mean it turns a bit left then a bit right.....what do i do?,,,,should i add delay in the random numbers generation?