CAPTCHA stands for Completely Automated Public Turing test to tell Computers and Humans Apart (wiki) and its main purpose is to provide a challenge-response scenario to make automated scripts fail.
There are two options to solve this problem:
1) Working with development team to disable CAPTCHA for test builds so that your automation scripts work. (Since you are trying on IRCTC public website, you cannot do that)
2) Or use third-party services (paid) such as DeathByCaptcha which uses OCR and other techniques to find the CAPTCHA code. The website says it takes an average of 1 min to find the CAPTCHA of the image supplied with ~94% accuracy.
Another SO post discussing about this and another blog post on API details.