Python code won't run?
<p>Hello i was wondering why this code will not run,thanks.</p>

<pre><code>count = 0
finished = False
total = 0
while not finished:
    number = int(input("Enter a number(0 to finish)"))
    if number == 0:
        finished = True
        else:
            total = total + number
            count = count + 1
print("the average is", total/ count)
count = 0
</code></pre>

<p>Your script is alright, you haven't indented properly the <code>else</code>clause, here's a working example, also, you should cast to float your average:</p>

<pre><code>count = 0
finished = False
total = 0

while not finished:
    number = int(input("Enter a number(0 to finish)"))
    if number == 0:
        finished = True
    else:
        total = total + number
        count = count + 1

print("the average is", float(total) / float(count))
count = 0
</code></pre>

<p>Another possible way to do the same with few lines would be this:</p>

<pre><code>values = []
while True:
    number = int(input("Enter a number(0 to finish)"))
    if number == 0:
        break

    values.append(number)

print("the average is", float(sum(values)) / float(len(values)))
</code></pre>

python python-3.x