Etta Mae Lopez
Etta Mae Lopez plans to quit smoking while in jail (Sacramento County Sheriff's Department)

A woman in California purposefully got herself jailed so that she could quit smoking.

Etta Mae Lopez, 31, slapped sheriff's deputy Matt Campoy. She had waited all day for a uniformed police officer to leave the building, the Sacramento Bee reported.

Lopez pleaded not contest to a charge of battery in court and was sentenced to 63 days in jail, where smoking is not allowed.

Campoy explained how he had tried to walk around Lopez as he left the jail through a group of family members who were loitering outside but that she attacked him.

"I stepped to the left again and she suddenly stepped into me and slapped my face," he said.

After she hit him, he took her into the police station where she hit him again.

"She waited all day for a deputy to come out because she knew if she assaulted a deputy she would go to jail and be inside long enough to quit her smoking habit," Campoy told the newspaper.

Lopez was sentenced to a further five days for violating her probation over a drink-driving conviction and told not to have any contact with deputies.