A teenager caught selling MDMA tablets in a town centre has avoided custody.
Emily Kelly was arrested after being caught with a tube filled with 39 tablets of the class A drug in Pontefract.
Leeds Crown Court heard police went to Cornmarket after receiving reports that someone had been caught on CCTV footage selling drugs on August 18 last year.
Mark Brooks, prosecuting, said Kelly was searched after the tube containing the tablets were found in her jeans pocket.
Kelly, 19, was interviewed at a police station and told officers she had been asked to "get rid" of the tube for someone.
She also admitted that she intended to sell them or pass them on to others.
Kelly was released on bail but arrested again three days later after being found in possession of drugs in Big Fellas nightclub, also in Pontefract.
Mr Brooks said security staff asked her to empty her pockets and she told them: "Yes I have got some pills on me."
Kelly, of Lee Way, Castleford, pleaded guilty to one offence of possession of a class A drug with intent to supply and possession of a class A drug.
Michael Morley, mitigating, said Kelly had pleaded guilty to the offences at an early stage.
Mr Morley said the offences happened at a time when Kelly was distressed after the relationship with a long-term partner came to an end.
Kelly was given a two-year prison sentence, suspended for two years, and ordered to do 250 hours of unpaid work.
This article was updated in order to the correct the total number of unpaid hours of work ordered during sentencing. The original report stated it was 150 hours.