Failing is a part of life. We are rarely good at something the first time we try. Consider how many times you fell off a bicycle before you mastered the ability to ride all around town.
The first thing to remember about school is that you are here to learn. If you knew the material, you would not need to be here. No one expects you to have mastered the course material on the first day, or even the 60th day.
When it comes to school, you may be able to make it all the way through without failing anything, but more likely you are not going to do well on something. Anxiety over one failure often leads to paralyzing fear of failing again, creating a self-fulfilling prophecy and dooming you. Oh no!
So, what do you need to do instead? Unfortunately, more work. You have to thoroughly examine your previous work to determine where you went wrong. Your professor probably put a lot of work into providing feedback. Use that to review your work, identify the exact place you went wrong, understand how you deviated from expectations, and prepare for the next time.
We usually learn more from our mistakes than our successes.