Q:

Creating normal distribution in python

I try to create a normal distribution in python. I made the following code:
    prior = []
    variance = 20
    mean = 0.5
    x = -100

    while x <= 100:
            normal_distribution = 1/np.sqrt(1*np.pi*variance*variance)*np.exp(np.power(x-mean,2)/(2*variance*variance))
            prior.extend(normal_distribution)
            ++x

But I got a type error: 
TypeError: 'numpy.float64' object is not iterable

I tried that the normal_distribution = ... Has a value outside the while loop.
I don't exactly understand why it can't iterate.

A:

There are three problems:

You are looking for .append, not .extend; this is the source of the error, as .extend requires iterable object as an argument, so it can append each of its elements to the list. You are adding a single element - this is what .append is for
Your equation for pdf is invalid, you should have

2 instead of 1 under the square root
negation inside exp
your variance variable is used in the meaning of std

1/np.sqrt(2*np.pi*variance)*np.exp(-(x-mean)**2/(2*variance))
There is no such thing as ++x in python, use x += 1

