# 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 while-loop and the string function find().
"""

import sys

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

c = sys.argv[2]

numC = 0
start = 0
while True:
    if (line.find(c,start) != -1):
        numC += 1
	start = line.find(c,start) + 1
    else:
        break

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

