I am working on a homework project and i have it all done but the beginning and i can't figure out why i keep getting either errors or weird outputs. the following is the snippet that i am having trouble with.
It keeps giving me an index error or when i change the parameters to the index it gives me the wrong output.
def line_sum_and_count(line):
"""Finds the sum and count of the numbers in the given line of text."""
#-----------------------------------------------------
split = string.split(line," ")
count = len(split)
for i in range(len(split)):
split[i] = float(split[i])
for n in range(len(split)):
sum = split[n] + split[n+1]
#-------------------------------------------------------
return sum, count
def test_line_sum_and_count():
"""Tester for the above function """
sum, count = line_sum_and_count('14.0 20.0 17')
if sum == 51 and count == 3:
print "passed"
else:
print "failed"