"A good way to keep a job is by having a good attitude" vs. "A good way to keep a job is to have a good attitude"
Which of the two sentences above is correct?
They both work for me. I prefer the second.
Remember - if you don't use correct capitalisation, punctuation and spacing, anything you write will be incorrect.