When did Lelouch take the Code from his father? When I was just searching for theories for why people believe Lelouch is still alive, I found a theory which says Lelouch took the Geass from his dad, so when he was killed he actually became immortal. But on re-watching the series I can't find any such scene where we see Lelouch taking the Code from his dad. Or did I miss something?

When I watched the anime for the first time, I remember it had extra scenes like Lelouch driving the cart, which wasn't present when I re-watched the series. I read that it was removed later.

So, did the writers remove the scene in which Lelouch takes the Code from his dad?
I am getting an impression that the writers had plans on keeping Lelouch alive, initially. They came out and said the ending was left ambiguous for the reader to interpret as they want, and then, they removed that scene and declared Lelouch is dead.
Lelouch never got Charles's code.
That was an old fan theory, but it was debunked by the community years ago.
The anime itself made it impossible and even the show staff have officially confirmed that Lelouch was truly dead.
So he never got a code or immortality.
There are also no scenes which show Lelouch as the cart driver. that's merely a fake fan-made video on youtube, it was never real. people made that to fool fans and to push their debunked conspiracy theory of him having a code.

All the official information regarding Lelouch's death can be found on the Code Geass Community Information Database. It has all the official statements, including sources, links, pictures, etc. It also shows how the anime made the fan theory impossible.

Here are some examples of official statements.

From "Geass Memories":
- "Before I started writing the story of a person called Lelouch, I confirmed with Taniguchi-director something. That thing was that the end of Lelouch will be death."
- "At least he is aware of his sins and pays for them with his death."
- "This man called Lelouch will pay for his sins by his death. The story follows him till he finally make this decision." 

From the official guide book:
- "For those two who bear the heavy sin known as killing their fathers, they share the belief that they can forgive each other by imposing the greatest punishments on themselves. Death for Lelouch who wishes for a tomorrow with his sister, life for Suzaku who wishes to atone for his sins through death."

From the remade epilogue from 2009 where they dropped the cart driver scene and replaced it with a brand new epilogue:
- "A young man dies. He had the power to change the world, to create a new order. The world feared him, hated him. But, I know he died with a smile on his face. Only those who have realised their dream will truly understand that feeling of utter contentment. So, this is not a tragedy. And whenever I feel sad or cry at night, I sing a song. A song of man's making. Zero Requiem!"   

All sources and many more examples can be found in the above linked Database