It struck me as I read Jesus assuring Simon Peter shortly before his crucifixion: "I have prayed for you that your faith will not fail."
Well, it did fail. He denied Jesus when confronted at the courtyard. So what is Jesus talking about? It seems to me he took into account, not just those moments of failure, but also the moment of grace when he repented and turned back. Taken together in chronological order, by the grace of God, Peter's faith did endure.
He has a longer, more complete view of things. We tend not to see that far because our lives are short and the long term can seem too great to contemplate. Thankfully, God takes the long view, and additionally, he stacks things in our favor by giving us the grace we need when we need it. It may take a while, and not according to our schedule, but in the long view of things, we can get by and more: we can triumph. One thing is needed, however: we need Faith. And even that is a gift.