Maladaptive operant conditioning contributes to development of neuropsychiatric disorders. Candidate genes have been identified that contribute to this maladaptive plasticity, but the neural basis of operant conditioning in genetic model organisms remains poorly understood. The fruit fly Drosophila melanogaster is a versatile genetic model organism that readily forms operant associations with punishment stimuli. However, operant conditioning with a food reward has not been demonstrated in flies, limiting the types of neural circuits that can be studied. Here we present the first sucrose-reinforced operant conditioning paradigm for flies. Flies of both sexes walk along a Y-shaped track with reward locations at the terminus of each hallway. When flies turn in the reinforced direction at the center of the track, sucrose is presented at the end of the hallway. Only flies that rest during training show evidence of learning the reward contingency. Flies rewarded independently of their behavior do not form a learned association but have the same amount of rest as trained flies, showing that rest is not driven by learning. Optogenetically-induced rest does not promote learning, indicating that rest is not sufficient for learning the operant task. We validated the sensitivity of this assay to detect the effect of genetic manipulations by testing the classic learning mutant dunce. Dunce flies are learning impaired in the Y-Track task, indicating a likely role for cAMP in the operant coincidence detector. This novel training paradigm will provide valuable insight into the molecular mechanisms of disease and the link between sleep and learning.SIGNIFICANCE STATEMENTOperant conditioning and mental health are deeply intertwined: maladaptive conditioning contributes to many pathologies, while therapeutic operant conditioning is a frequently used tool in talk therapy. Unlike drug interventions which target molecules or mechanisms, it is not known how operant conditioning changes the brain to promote wellness or distress. To gain mechanistic insight into how this form of learning works, we developed a novel operant training task for the fruit fly Drosophila melanogaster. We made three key discoveries. First, flies are able to learn an operant task to find food reward. Second, rest during training is necessary for learning. Third, the dunce gene is necessary for both classical and operant conditioning in flies, indicating that they may share molecular mechanisms.