I work in a nursery - any kid that hears bad language will repeat bad language. Maybe because they think it's a regular word, maybe because they realise it is an expression of anger, maybe just to try it out.... but generally, kids of nursery age don't get the concept of "words you aren't allowed to use". They're too young to understand why some words aren't for them.
And punishing them for repeating what they've heard is a little harsh - that's how kids learn to talk! They all repeat language!
The best success we've seen with kids who were using swear words in nursery, is when the parents just totally stopped using bad language around their kid. They soon forget words if they don't hear them regularly.
When a kid at nursery swears, I tend to start with a puzzled look and say "oh, I don't know that word, it doesn't make any sense to me, maybe you meant 'this funny toy isn't working'...? THAT makes sense to me - what a frustrating toy it is!" And give them an alternative word to use, pretending they must've mis-heard and mis-repeated. For kids that don't hear swearing often, this is usually the quickest approach to stopping it.
If it is persistently used bad language, we still wouldn't punish usually, as again it's not their fault they're exposed to it, and developmentally they do parrot new language to learn, but I would say "that's not a very good word choice. Sometimes adults use that word if they're cross, but I don't like to hear it, so maybe you could say 'xxxx' instead. (Eg 'stinky') How about we call that toy a stinky toy instead?"
I realise this is still not the desired end goal, as you don't really want kids shouting about stinky toys etc (!), but giving them an alternative word that they find funny/rude, but that is more harmless will help them forget the swear word. And giving them permission to use the new word makes it less appealing, so they tend to opt for using neither once the novelty of calling something "stinky" has worn off ;) so long as they stop hearing the swear word at home.
I've never yet had a kid turn round and say "nah, I'm not going to call it a stinky toy car, I'm gonna keep calling it a f**king toy car"...! They are fairly easy to suggest new and different language to, so choose the words you are happy with, and get them to repeat their sentence using your chosen replacement instead.
Teach her how to be frustrated in an appropriate way, rather than punish her for repeating bad language when she thinks that's how it's meant to be used.