How to display specific lines in a file?

38 Views Asked by At

So working on an assignment that has a file like so, qbdata.txt:

Carson Palmer QB CIN   362 586 3970    26  20  61.8%   82.4    
Alex Smith QB SF   204 342 2370    14  10  59.6%   82.1    
Chad Henne QB MIA  301 490 3301    15  19  61.4%   75.4    
Tony Romo QB DAL   148 213 1605    11  7   69.5%   94.9    
Jay Cutler QB CHI  261 432 3274    23  16  60.4%   86.3    
Jon Kitna QB DAL   209 318 2365    16  12  65.7%   88.9    
Tom Brady QB NE    324 492 3900    36  4   65.9%   111.0

I need to modify a for loop and make a list and just print the DAL QB and their rating, what I have is:

qbfile = open("qbdata.txt", "r");

for aline in qbfile:
    values = aline.split()
    if aline = 4:   
         print('QB ', values[0], values[1], 'had a rating of ', values[10] )
    if aline = 6:
         print('QB ', values[0], values[1], 'had a rating of ', values[10] )
qbfile.close();

Tried a few different things and looked at other posts but can't seem to figure it out..

0

There are 0 best solutions below