Proof that for an effective divisor $l(D)\leq \deg D +1$
In one of my recent questions I got this answer: https://math.stackexchange.com/a/4348876/645867. In particular, it is said that "for an effective divisor $l(D)\leq \deg D +1$ and equality holds iff $D=0$ or $g=0$".
Where can I find a proof of this fact?
First, observe that we have equality when $D=0$ or $g=0$: $h^0(X,\mathcal{O}_X)=1$ for any smooth projective curve, while $h^0(\Bbb P^1,\mathcal{O}_{\Bbb P^1}(D))= h^0(\Bbb P^1,\mathcal{O}_{\Bbb P^1}(\deg D))=\deg D+1$ for any effective divisor on $\Bbb P^1$.
Next, we'll reuse some material from the proof of the Riemann-Roch theorem. We have for any divisor $D$ and any point $P$ on a curve $X$ an exact sequence of sheaves $$0\to \mathcal{O}_X(D)\to\mathcal{O}_X(D+P)\to k(P)\to 0.$$ Taking global sections, we get that either $l(D+P)=l(D)$ or $l(D+P)=l(D)+1$. Now write $D=\sum_{i=1}^d P_i$, let $D_j=\sum_{i=1}^j P_i$ and consider the sequence $\{l(D_j)\}_{0\leq j \leq d}$: this is a sequence which starts with $1$ and increases by at most 1 each time the index does. So $l(D)=l(D_d)\leq d+1$, with equality implying $l(D_1)=2$. But $l(D_1)=2$ means that there's a nonconstant meromorphic function on $X$ with a single pole at $P_1$, which implies that $X$ has a degree-one map to $\Bbb P^1$, or that $X\cong \Bbb P^1$. So $l(D)\leq \deg D+1$, with equality iff $D=0$ or $g=0$.
HINT:
You don't need much knowledge to prove it. Assume that we have $l(D) \ge \deg D +2$, and get a linear combination of rational function without poles and non-constant, contradiction.