Syntax error: unexpected EOF while parsing. Am I inputting incorrectly?
<p>While trying to solve <a href="http://www.usaco.org/index.php?page=viewproblem2&amp;cpid=94" rel="nofollow" title="this">this</a> computer olympiad problem, I ran into this error:</p>

<pre><code>Traceback (most recent call last):
File "haybales.py", line 5, in &lt;module&gt;
    s = input()
File "&lt;string&gt;", line 0

^
SyntaxError: unexpected EOF while parsing
</code></pre>

<p>My current code looks like this:</p>

<pre><code>hay = []
s = input()
while s != 'END':
    hay.append(s)
    s = input()

    for i in hay: #adds all integers in array
        var = var + i

       if var % hay[0] == 0:
            average = var / hay[0] #finds average of all numbers in array

            for bale in hay:
                diff = bale - average
                total += diff 
                #finds sum of all differences to find the final answer

             print 'you need to move' + str(total) + 'piles of hay'

        else:
            print 'it\'s not possible to make them equal'
</code></pre>

<p>Are my inputs being read incorrectly?
How can I change my code to resolve the error?</p>

<p>There are a number of problems with your code:</p>

<ul>
<li><p><strong>Indentation</strong>: 
In Python indentation is very important. You can't ignore it, or your code will either fail to run or give unexpected results. This may be due to the way you pasted the code into stack overflow, which I admit can sometimes be troublesome, but it's best to mention it just in case.</p>

<pre><code>hay = []
s = input()
while s != 'END':
    hay.append(s)
    s = input()

for i in hay: #adds all integers in array
    var = var + i

if var % hay[0] == 0:
    average = var / hay[0] #finds average of all numbers in array

    for bale in hay:
        diff = bale - average
        total += diff
        #finds sum of all differences to find the final answer

    print 'you need to move' + str(total) + 'piles of hay'

else:
    print "it's not possible to make them equal"
</code></pre></li>
<li><p><strong>input</strong>:
You should convert your input to an integer to allow the calucation to function correctly. Ideally you would also validate the input, but that's another topic. Here, just change line 4:</p>

<pre><code>hay.append(int(s))
</code></pre></li>
<li><p><strong>Scope</strong>: 
Visibility of variables is a little off in your code. On line 8 for example, you attempt to add a value to var. But each time you run through the loop var is a new variable and will cause an error. (var is not defined). This is also a problem for Total.</p>

<pre><code>hay = []
s = input()
while s != 'END':
    hay.append(s)
    s = input()

var = 0 ###ADD var HERE
for i in hay: #adds all integers in array
    var = var + i

if var % hay[0] == 0:
    average = var / hay[0] #finds average of all numbers in array

    total = 0 ###ADD total HERE
    for bale in hay:
        diff = bale - average
        total += diff
        #finds sum of all differences to find the final answer

    print 'you need to move' + str(total) + 'piles of hay'

else:
    print "it's not possible to make them equal"
</code></pre></li>
<li><p><strong>Calculation</strong>: 
Average is the sum of all values divided by the number of values.
hay[0] is the first value, not the number of values. To get the number of values entered you can use the len() function.</p>

<pre><code>hay = []
s = input()
while s != 'END':
    hay.append(s)
    s = input()

var = 0;
for i in hay: #adds all integers in array
    var = var + i

if var % hay[0] == 0:
    ###CHANGE BELOW LINE TO USE len(hay)
    average = var / len(hay) #finds average of all numbers in array

    total = 0
    for bale in hay:
        diff = bale - average
        total += diff
        #finds sum of all differences to find the final answer

    print 'you need to move' + str(total) + 'piles of hay'

else:
    print "it's not possible to make them equal"
</code></pre></li>
<li><p><strong>print</strong>:
When you print remember to add a space before and after your concatenated (joined) string:</p>

<pre><code>print 'you need to move ' + str(total) + ' piles of hay'
</code></pre></li>
</ul>

<p>Otherwise there will be no space when you get your output.</p>

<p>I hope this helped.</p>

python