Attempt comes under sec 511 of IPC.

There are 4 stages of crime:
4.Commissioning of a crime.
So law does not recognizes any crime in forming an intention and to some extent prepratio,for preparation only preparation like raging war against nation (sec 122) and other criminal acts related to preparation.
So the question arises about attempt:
What is an attempt?
So the answer to this question is that:
An attempt is an act done in the prosecution of commissioning of an offence, but because of an intervening act against the will of an offender the act fails.
In Abhayanand mishra v state of Bihar it was stated that there is very thin line between attempt and preparation. To distinguish between these two the circumstances of the case play a vital role. Between attempt and preparation there is always a chance of retreat by an offender or might there is change in intention in not doing that offence, but as soon as the offender moves ahead and acts in the commissioning of crime but his attempt fails because of an intervening act then the case comes within an ambit of attempt(Sec 511).
Ingredients of sec 511 are:
1. mens rea.
2. Preparation.
3. An act done by an offender to satisfy mens rea.
4. An intervening act done  to stop the offence against the will of an offender.
For example A decides to kill B(Mens Rea) He buys gun(preparation) goes to the B house(here is the window is open for offender to retreat back) he pulls the trigger pointing on B(Attempt/He enters danger zone and now the offence comes under 511,307(attempt to murder)).C comes and hits A and he misses B(Intervening act done by C against the will of A).
So if that intervening was not done by C it surely have killed B and A would be successful in its act.But failed act of A comes under 511,307 section.