I have a program that makes various calculations based on text provided in a text file. I get an error after the second entry is printed (the first works fine.)
The entry in the file is parsed to be a list:
['Castro, Starlin', 'CHC', '161', '666', '59', '163', '34', '2', '10']
I then make a call to the singles function, which takes four arguments.
singles = singles(float(line[5]),float(line[6]),float(line[7]),float(line[8]))
print "Singles: %s" % singles
The function is as follows:
def singles(a,b,c,d):
# a = hits b = doubles c = triples d = homeruns
# hits - (doubles + triples + homeruns)
tmp1 = b + c + d
return a - float(tmp1)
This works fine for the first entry:
['Machado, Manny', 'BAL', '156', '667', '88', '189', '51', '3', '14']
and the calculation successfully completes. However, the second is unable to complete:
Traceback (most recent call last):
File "\\bhmfp\ian.carroll$\Intro to Computer Programming\Project 3\Project 3\main.py", line 107, in <module>
singles = singles(float(line[5]),float(line[6]),float(line[7]),float(line[8]))
TypeError: 'float' object is not callable
floatorsinglessomewhere?singles = singles(...).