Complexity Class of an Algorithm with two Inputs
You're confused because you've called part of your input&nbsp;$n$. When we say that the running time is some function of&nbsp;$n$, we almost always mean that $n$&nbsp;is the length of the input string.

Your algorithm runs in time $|P|^L$, where $P$ is a string contained in the input and $L$&nbsp;is a number represented in the input, presumably in binary.  If $L$&nbsp;is a $b$-bit number, it could be as big as&nbsp;$2^b$.  Writing $n$ for the length of the input, we could, for example, have $|P|=n/2$ with $L$ being an $(n/2)$-bit number.  That case gives running time $(n/2)^{2^{n/2}}$, which is a long, long way from being polynomial.