I open a list into my script and the search for matches to '2011' and print the '2011' strings using the following code
for row in dL:
if "2011" in row:
print row
and get the following output
['2011', 'randome', '6200']
['2011', 'marks', '6020']
['2011', 'man', '6430']
['2011', 'is', '6040']
['2011', 'good', '6230']
what I am trying to do is get all the values from the 3rd column and sum them to get the result 30920 and then calculate and print the average which is 6184. So far I have the following code.
total = int(row[2])
total2 = sum(total)
print total2
however I get the following error
total2 = sum(total)
TypeError: 'int' object is not iterable
How can I fix this error and create the total and averages??