The following is an exercise from pg 5 of this document on Picard Groups:
Let $Z$ be a prime divisor in a smooth variety $X$, and let $U$ denote the complement $X\setminus Z$. Show that the sequence $$\Bbb{Z}\to \text{Pic}(X)\to \text{Pic}(U)\to 0$$ is exact. The map from $\Bbb{Z}\to \text{Pic}(X)$ is of the form $1\to Z$, where $Z$ is the previously chosen prime divisor.
Now use this result to prove that $\text{Pic}(\Bbb{P}^n)=\Bbb{Z}$ for any $n\in\Bbb{N}$.
I may be doing this wrong, but I think the map from $\Bbb{Z}$ to $\text{Pic}(X)$ is the zero map, as $Z$ corresponds to a principal divisor in $\text{Div}(X)$. Also, the map $\text{Pix}(X)\to \text{Pic}(U)$ is the identity map.
If both of these are true, which I don't think they are, then I have no way of proving that $\text{Pic}(\Bbb{P}^n)=\Bbb{Z}$. Am I understanding the exact sequence given above incorrectly.
$Z$ has no reason to be a principal divisor, e.g if $Z \subset \Bbb P^2$ is a line. In any case you have a map $\Bbb Z \to Pic(X), 1 \mapsto [Z]$.
The map $Pic(X) \to Pic(U)$ is given by restriction :$D \mapsto D \cap U$ where $D$ is a prime divisor and extend by linearity. In particular the composition is zero and your sequence is indeed exact. Surjectivity is because any divisor $D \subset U$ can be extended to a divisor $\tilde D \subset X$ (just take the closure).
Now $Pic(\Bbb A^n) = 0$ because $k[x_1, \dots, x_n]$ is a UFD. So you have a surjection $\Bbb Z \to Pic(\Bbb P^n)$ by taking the image of an hyperplane, and it's easy to see that this map is a bijection.