I just did the listening Mondai 2 for Lesson 33 of Minna No Nihongo 2 (the older ver.). And in question 5, it says「山田君は 今の試合で 失敗しましたが、次の試合で 頑張ります。」
I've learned that you use 「に」before 「失敗する」, and I don't know why it uses 「で」here instead.
What does「で」mean here? And how do I know when to use 「で」or「に」?