In John 12:35, Jesus instructs the crowd to walk while they have the light. And presumably he is commanding them to walk in the light, since the opposite disposition at the end of the verse is walking in the darkness.
Walking is a way of describing the course of one’s life and as is common in the writings of John, one is either walking in the light OR walking in the darkness. In this context, it’s a very similar idea as following Christ, so Jesus is instructing this crowd to take heed to his teaching and walk in his ways while they can learn directly from him, who again is the fullest revelation of God ever given.

Then Jesus states a purpose for the necessity of obeying his command; it’s so that darkness will not overtake them. This is the same verb that is found in 1:5, where John writes that the darkness did not overtake the Light. So whereas the darkness cannot overtake Jesus, who is the Light, the darkness can certainly overtake the one who does not walk in the Light. No one stands a chance against the powerful pull of the world and the sinister schemes of Satan apart from possessing the Light of Christ. In this context, once Christ ascends to heaven, the Jews will enter into a time of great darkness as the judgment for rejecting him comes upon them at the ruthless hands of the Romans. It will be much easier to have hope in God at the time of John 12, as God incarnate is standing before them, then when the holy city and the temple are in ruins.

Jesus concludes v.35 with these words—the one walking in the darkness doesn’t know where he is going; he’s clueless; he’s aimlessly going about.  The Jews thought they had all the revelation and insight they needed, but in fact, Jesus refers to the system of Judaism as the blind leading the blind. So just like there is no way to find your way around an old, abandoned, dark building, there’s no way to have any spiritual clarity without Jesus.  If someone does not have Jesus, they are going nowhere in this life and heading for eternal judgment in the next.  Since the ramifications of failing to walk in the light are massive, Jesus’ exhortation becomes all the more instructive and gracious.