Confused by results from simple calculation
<p>I am not sure why the below code is not working. I am running this in python 3.5.2 and the problem appears to be in the calculation portion of the code. It returns no errors but gives huge values that shouldn't be the average of the 5 inputs.</p>

<pre><code>#inputs
year1 = input("Enter wins for year 1: ")
year2 = input("Enter wins for year 2: ")
year3 = input("Enter wins for year 3: ")
year4 = input("Enter wins for year 4: ")
year5 = input("Enter wins for year 5: ")

#calculation
averageWin = int(year1 + year2 + year3 + year4 + year5) / 5
#output
print ("Average wins are", averageWin)
</code></pre>

<h2>By default, <code>input()</code> returns a string. You are adding the strings and then converting the result into an <code>int.</code></h2>

<p>Assume we have the inputs <code>1, 2, 3, 4, 5</code> as our variables. Your code does <code>'1'+ '2' + '3' + '4' + '5'</code> instead of <code>1 + 2 + 3 + 4 + 5</code>. Your result is <code>'12345'</code> instead of <code>15</code>. So you are dividing 12345 by 5 instead of 15. To fix this, put <code>int()</code> around each of your <code>input()</code> calls, to convert those answers into numbers. </p>

python python-3.x average