How is this integral being evaluated? (Please don’t solve a explanation would be appreciated) Okay so I am new to definite integrals so I might be wrong but I’d really appreciate a hint or a explanation what is happening here but not the solution.
Sorry about the stupid orientation it just does that I don’t know how change it. 

$$\begin{aligned}
\int_0^\pi \frac{dx}{1+\sin x} &= \int_0^\pi \frac{1-\sin x}{1-\sin^2 x} dx \\ &= \int_0^\pi \frac{1-\sin x}{\cos^2 x} dx \\
&= \int_0^\pi \sec^2 x - \frac{\sin x \sec x}{\cos x} dx \\ &= \int_0^\pi \sec^2 x - \tan x\sec x\ dx \\ &= \int_0^\pi \sec^2 x\ dx - \int_0^\pi \tan x\sec x\ dx
\end{aligned}$$
Here the integral is continuous in the starting but in the last step right above the sec^2x graph sec^2x is discontinuous at pi/2 and

( I couldn’t draw tanx.secx graph) 
We find it is also discontinuous at pi/2 
 So how Can the integrals be evaluated?  They have done it in my book by simply substituting after evaluating the last last step in picture 1. 
Where am I going wrong I’d really appreciate if I could get some explanation or a hint but not the solution.

This is a keen observation, and you're correct that the last inequality requires justification beyond the linearity of Riemann integration, exactly because the integrands of the two separate integrals both have singularities at $x = \frac{\pi}{2}$. The previous integral,
$$\int_0^{\pi} (\sec^2 x - \sec x \tan x) \,dx ,$$
does not have this problem. Now, it's true that the integrand isn't defined at $x = \frac{\pi}{2}$, but the integrand remains bounded near that point, so this doesn't affect the value of the Riemann integral. In fact, this singularity is removable: We can assign the integrand a value at that point, namely $0$, to make it a function continuous on the entire interval of integration, which is what we need to apply the Fundamental Theorem of Calculus. We'll do exactly this to evaluate (and more to the point justify the evaluation of) the original integral.
Even though we can't split up the integral by linearity---at least not without some other justification, like introducing improper integrals, which OP hinted in the comments he hadn't encountered yet---we can still look separately for antiderivatives of each summand separately. These are both elementary, and we get that $(\tan x)' = \sec^2 x$ and $(\sec x)' = \sec x \tan x$, so by linearity of the derivative, $\tan x - \sec x$ is an antiderivative of the original integrand, at least everywhere (in the interval of integration) other than $x = \frac{\pi}{2}$.
We again have to wrangle with the fact that $\tan x - \sec x$ isn't defined at $x = \frac{\pi}{2}$, and again this singularity removable. We can check this quickly by rewriting $\tan x - \sec x = (\tan x - \sec x) \cdot \frac{\tan x + \sec x}{\tan x + \sec x} = -\frac{1}{\tan x + \sec x}$, which tends to $0$ as $x \mapsto \frac{\pi}{2}$. In order to apply the usual version of the F.T.C., we also need to check that the function $\tan x - \sec x$ (with the singularity removed) is differentiable at $x = \frac{\pi}{2}$, which I'll leave as an exercise. With this in hand, we have that
$$(\tan x - \sec x)' = \sec^2 x - \sec x \tan x ,$$ where now both $\tan x - \sec x$ and $\sec^2 x - \sec x \tan x$ represent the functions with the respective singularities removed, and so the F.T.C. gives
$$\int_0^{\pi} (\sec^2 x - \sec x \tan x) \,dx = (\tan x - \sec x) \vert_0^{\pi} .$$
