getting the average of serial port data
Question: i have a python code which reads serial data through RS232

    
    
    import serial
    import time
    
    ser = serial.Serial('/dev/ttyUSB0', 2400, timeout=1)
    
    while True:
    str1 = ser.read(1)
    if str1 == '':
        print 'no data on line'
    else:
        print str1 
    

this returns me

    
    
    no data on line
    no data on line
    no data on line
    no data on line
    206
    210
    212
    200
    

it's mic-reading values let's assume those numbers are degrees to move a motor
i want to get the avarage number to move the motor to it.


Answer: 
    import serial
    import time
    data_sum = []
    ser = serial.Serial('/dev/ttyUSB0', 2400, timeout=1)
    
    while True:
        str1 = ser.read(1)
        if str1 == '':
            print 'no data on line'
        else:
            data_sum.append(int(str1)
    
    ave = sum(data_sum)/len(data_sum)
    

