Code and its close cousin, configuration, take time and hard work. Code needs configuration to run, such as Raspbian configuration, extra software, and necessary data files. Both need research and learning, design, making them, testing, and debugging.
Many bad situations can lead to the loss of code. These have happened to me a week before taking robots to a show, after weeks of work, and I learned the hard way to take this quite seriously. So, what can happen to your code?