I'm going to assume that the question asks for the probability that none of $N$ independent and identically distributed random variates drawn from the discrete uniform distribution $U[0,M)$ will be equal to separate random variate drawn from the same distribution.
The general case is quite easy. This is a binomial distribution, with parameter $p=\frac1M$. The probability that one given person will draw the correct number is exactly equal to $p$. The probability that that person will not draw the correct number is $1-\frac1M = \frac{M-1}M$. The probability that not a single one of the $N$ people involved in the experiment will draw the given number is $$P=\left(\frac{M-1}M\right)^N$$
In the case where $N=1000, M=1001$ (e.g. the code), this becomes $\left(\frac{1000}{1001}\right)^{1000} \approx 0.36806$. If $N=M=1000$ (the intent of the question?), this becomes $\left(\frac{999}{1000}\right)^{1000} \approx 0.36770$. Note that both are quite close to $1/e \approx 0.36788$. This is not a coincidence. Both $\left(\frac{N}{N+1}\right)^N$ and $\left(\frac{N-1}N\right)^N$ are fairly good estimates of $1/e$ for large $N$; the average of the two is an even better estimator of $1/e$.
I ran a simulation in Python to do this 10000 times, and in 37.22% of the cases, no one chose the $x$.
You are overstating the precision of your Monte Carlo simulation. It would have been much better to have said 37% rather than 37.22%. Your 10000 cases yield about two decimal places of accuracy. You would need to run that Monte Carlo simulation about one million times to get three places of accuracy, and about 100 million times to get four places of accuracy.
I'm a big fan of what I call "dumb Monte Carlo" because it's so easy to set up. That said, it is indeed "dumb" because of the logarithmic growth of precision that results. Better techniques do exist (e.g. bootstrap, jackknife, Markov chain Monte Carlo), but these are a bit trickier to set up.
randint(0,999)
in your code (rather thanrandint(0,1000)
). $\endgroup$