Thank-you, but can you please will this work if i'm reading the file from a list? My project requires me to create a def function that can convert the list of numbers into a number before I can get the average. Btw am I able to put anything in the brackets at the last line you've indicated? Sorry for being so noob :(

Thank-you, but can you please will this work if i'm reading the file from a list? My project requires me to create a def function that can convert the list of numbers into a number before I can get the average. Btw am I able to put anything in the brackets at the last line you've indicated? Sorry for being so noob :(

"...reading the file from a list?" You mean reading a file into a list? If so, please post the contents of the file between [CODE=text]
[/code] tags so we can see how many numbers per line, what character occurs between the numbers (space, tab, comma, etc.) and what other characters are in the file besides numbers.

By "...convert the list of numbers into a number before I can get the average" do you mean add the list of numbers to get a total? That's what sum(numList) does in snippsat's function.

Okay I didn't want to give the whole project that i had to try and do, but it is obvious I'm too dum to learn even python. I really appreciate your help and others. This is the file (list) i have from school exactly like this.

60,70,66
85,74,80
83,91,72
75,62,72

My project is to define two function, 1. to convert it to a number then 2. to get the average. Can anyone please show me how the definition should be in the most simplest way. So, I'll have a total of 3 programs. the main will call the the two functions within the program.
@tonyjvk,
Thank-you :)

Btw, I am really new to python, meaning dum new, but I want to learn thou :), I just need some guidance and help from all the pros that know how. I REALLY APPRECIATE ALL YOUR HELP :)

Hope this leaves something to you to do but helps you to get started, I left out the file input part with looping.

def avg(seq):
"""divide sum of sequence by it's length to get average, make sure
Python 2 does not use integer division by making float the sum
"""
return float(sum(seq))/len(seq)
line_of_numbers = "60,70,66"
# get numbers separated with , as number to list numbers
numbers = [float(number_string) ## change to real float numbers
for number_string in line_of_numbers.split(',')]
print ('Sum of numbers %s is %.2f and they are %i, that makes average %.2f' %
(numbers, sum(numbers), len(numbers), avg(numbers)))

Thank-for trying to help me, but I think I'm more lost now lol. I think I have to really search for the dum version of how to do python ====> me :(.

Could you understand this version which does not save the numbers to list, easier:

def avg(total,count):
return float(total)/count
line_of_numbers = "60,70,66"
# get numbers separated with , as number to list numbers
total, count = 0.0, 0
for number in line_of_numbers.split(','):
print number # debug print
total += float(number)
count += 1
print 'Total:', total, 'count', count
print 'Average:', avg(total,count)