It is the gun. The Cobra is one of the cheapest guns on the market, and this is reflected in the quality control. If you can, take it back to where you bought it and exchange it for another one. Keep doing that until you get one that works. This should not take many tries if you stick to round-nose, full-metal-jacket ammunition, because these are very simple guns.
Just for the record, though, I would suggest you get a refund, if possible, save up another $100-$125, and then get something of much better quality, like a Hi-Point. Hi-Points are also very simple, but they have a much better reputation for reliability. They are kind of bulky, though.
Or save up the refund and another $150-$200 and get something of better quality AND far more modern design, like a Ruger LCP or a Kel-Tec .32 or .380. The Kel-Tec .32s are very cheap these days, and they are reliable with "hollow point" expanding bullets, which is what all policemen in the US use now. I would rather have a .32 with hollow points than a 380 with RN-FMJ, but that is a personal preference and the subject of much argument.
Hollow point ammunition does cost more, but if you are really tight for money, you are not going to be shooting it much anyway. And if you become able to practice more, a Hi-Point, a Ruger or a Kel-Tec will be more durable than a Cobra anyway.
PS - I am NOT going to tell you that a Cobra is junk. It is decent value for the money, BUT it costs very little money. There are times when you really HAVE to have something, like a car or a firearm, and the cheapest may be all you can get, But just like with cars, if you wait a while and save up some more money, you will be much better off (and money ahead in the long run).
I apologize if I am telling you things you already know very well. I am getting older, and I seem to do that more and more. Good luck!