I get an error with this code and I dont know why I thought that sum was part of the array calss and it does come up when I put the "." after the array. This is the error I get.
Traceback (most recent call last):
File "F:/Python_Stuff/CSC143-901/score-array.py", line 22, in <module>
print 'The Home team score is ', homescore.sum
AttributeError: 'array.array' object has no attribute 'sum'
Below is my code. The loop is just 2 now for debug
#use arrays to track baseball scores from array import * #yearArray = array('i', [1776, 1789, 1917,1979]) print """you are entering score for 9 innings of a ball game for the home \n and visiting teams in the program. """ #Make arrays for teams score homescore = array('i',) visitingscore = array('i',) # Loop for the 9 inning ball game for x in range(0,2,1): home = int(raw_input('The home team score this inning. ')) homescore.append(home) # Loop for the 9 inning ball game for x in range(0,2,1): visiter = int(raw_input('The visiting team score this inning. ')) visitingscore.append(visiter) print 'The Home team score is ', homescore.sum print 'The Visiters team score is ', visitingscore.sum #Decide who wins if homescore.sum > visitingscore.sum: print"The Home team wins!" else: print"The visiting team wins!"