The comet nucleus is pushed away from the solar system and leaves it altogether. The comet nucleus is nudged inwards and races towards the sun, circles it and goes back to return after hundreds or thousands of years. The comet Hyakutake which delighted millions of people around the world in March 1996 was one such comet. The comet nucleus is deflected by a large planet like Jupiter as it races towards the sun. With its path so altered, it goes round and round the sun with a period shorter that 200 years.
Astronomers call such comets short period comets.
The famous comet Halley is a short period comet deflected by the planet Jupiter and has a period of about 76 years. Sometimes these comets can also be captured by Jupiter. This is what happened to the comet Shoemaker - Levy 9, perhaps a hundred years before it crashed into Jupiter in July 1994. The orbits of over 700 comets are known. About a 100 of them have periods shorter than 200 years.