Python nested for loop
<p>I have a file called <code>!input.txt</code> containing multiple lines, each line is a random integer from 0 to 10.
I want to write a program that reads the file and calculate how many times each integer (0-10) appears in the file. For example, if there are four "0", two "3" and five "7" in my input file, the program will print out something like this: </p>

<pre><code>Number of occurrences of 0: 4
Number of occurrences of 1: 0
Number of occurrences of 2: 0
Number of occurrences of 3: 2
Number of occurrences of 4: 0
Number of occurrences of 5: 0
Number of occurrences of 6: 0
Number of occurrences of 7: 5
Number of occurrences of 8: 0
Number of occurrences of 9: 0
Number of occurrences of 10: 0
</code></pre>

<p>Here is my code:</p>

<pre><code>mylist = [0,1,2,3,4,5,6,7,8,9,10]
countlist = []
inFile = open("!input.txt", "r")
count = 0

for digit in mylist:
    for line in inFile:
        if digit == int(line):
            count = count + 1
    countlist.append(count)
    count = 0

#Print out the result#
for i in range(11):
    print("Number of occurrences of {0}: {1}".format(i, countlist[i]))
</code></pre>

<p>The result comes out like this:</p>

<pre><code>Number of occurrences of 0: 4
Number of occurrences of 1: 0
Number of occurrences of 2: 0
Number of occurrences of 3: 0
Number of occurrences of 4: 0
Number of occurrences of 5: 0
Number of occurrences of 6: 0
Number of occurrences of 7: 0
Number of occurrences of 8: 0
Number of occurrences of 9: 0
Number of occurrences of 10: 0
</code></pre>

<p>I guess there's something wrong with my nested for loop, but I couldn't figure out what it is. Please help.</p>
