How do you use but in sentence?

We can use but in a sentence. but it is not necessary to use it in the front or end.

We were going to have trifle for tea but we forgot the cream.
Jenifer loved to play games on her computer, but her mum made her switch it off at ten pm.