how to iterate through each set

Tom_chicollegeboy tbabula at gmail.com
Sun Nov 4 02:00:28 EST 2007


I figured out problem. here is my code. now it works as it should!
Thank you everyone!

def speed():
    infile = open('speed.in', 'r')
    line = infile.readline()
    read = int(line)
    while '-1' not in line:
        i = 0
        t0 = 0
        v = 0
        if len(line.split())==1:
            read = int(line)
            while i<read:
                line = infile.readline()
                list1 = line.split()
                s = int(list1[0])
                t1 = int(list1[1])
                t = t1- t0
                v += s*t
                i+=1
                t0 = t1
            print v
        line = infile.readline()
    infile.close()

speed()




More information about the Python-list mailing list