# numchar2.py
# Written by Todd Wareham for CS 2500
"""
Given the name of a textfile and a character c as command-line arguments, computes and
 prints the number of occurences of c in the file.

This version is implemented using a for-loop.
"""

import sys

if len(sys.argv) != 3:
    print "usage:", sys.argv[0], " filename character"
    sys.exit(1)

f = open(sys.argv[1], "r")
line = f.read()
f.close()

c = sys.argv[2]

numC = 0
for x in line:
    if (x == c): numC += 1

print "Num", c, "=", numC

