TITLE: A question on the Picard group
QUESTION [5 upvotes]: Let $X$ be a simply connected smooth projective variety, whose Picard group is generated by the classes of the irreducible codimension 1 loci $D_1, \ldots, D_k$. Let $E_1, \ldots, E_r$ be other irreducible codimension 1 loci, and suppose that $X^0$ is the complement in $X$ of the divisors $D_i$ and $E_j$.
Suppose now that $X_0$ is the complement of $n$ irreducible loci of codimension $1$ in $Y$, a smooth projective variety.
Question: Can I conclude that the Picard group of $Y$ has rank $n-r$?
I can answer the question affirmatively over $\mathbb{C}$, by using the long exact sequence with compact support associated with the inclusion $Y \setminus X^0 \to Y$, but I would like to know if there is an algebraic proof of this (valid over any algebraically closed field $k$).
EDIT: As pointed out in the answer, I am actually assuming that the Picard group of $X$ is FREELY generated by the $D_1, \ldots, D_k$.

REPLY [2 votes]: I'm going to assume that $X^0$ is the same as $X_0$ and that the Picard group of $X$ is freely generated by the $D_i$, since without that the question doesn't make much sense. In this cases, the answer is yes. This is the same as Mohan's answer, but with a little more detail.
The relevant tool is that if $Z$ is a normal variety and $D$ is an irreducible divisor in $Z$, there's an exact sequence:
$$
0 \rightarrow \mathcal O(Z)^* \rightarrow \mathcal O(Z \setminus D)^*
\rightarrow \mathbb Z \rightarrow
\operatorname{Cl}(Z) \rightarrow \operatorname{Cl}(Z \setminus D) \rightarrow 0
$$
Here $\mathcal O(Z)^*$ denotes the ring of global functions on $Z$.
I'm writing $\operatorname{Cl}$ instead of $\operatorname{Pic}$ because this applies to the Weil divisor group of an arbitrary normal variety. The right part of this exact sequence is Proposition II.6.5 in Hartshorne and it's not hard to see that the left part is also exact.
What this means is that we can define the ``virtual class rank'' of a variety $Z$ over a field $K$ to be
$$\operatorname{rank} (\operatorname{Cl}(Z)) - \operatorname{rank}(\mathcal O(Z)^* / K^*),$$
at least when these ranks are finite. Then, the exact sequence tells us that removing an irreducible divisor drops the virtual class rank by exactly 1. In your case, $X$ is projective, so it has no non-constant regular functions, so its virtual class rank is the rank of its class group, $k$. By induction, the virtual class rank of $X^0$ is $-r$ and for $Y$ it is $n-r$, which is again the rank of the class group of $Y$, because it is projective.
This only tells you about the rank of the torsion-free part of $\operatorname{Pic}(Y) = \operatorname{Cl}(Y)$. If part of your question was whether this Picard group is torsion-free, I'm not sure what you can say about that.