Python read from text file II

You are given a file called prolazStudenti.txt, where each line of the file contains a one-word student username and three test scores separated by spaces, like below:

GWashington 83 77 54
JAdams 86 69 90

Write code that scans through the file and determines how many students passed all three tests. You passed if your score is 51 and above.


students = [line.strip() for line in open('C:/Users/ZM/Desktop/Documents/New folder/prolazStudenti.txt')]
L = []
for i in students:
    L.append(i.split())
K = []
for i in L:
   
for j in i:
      
if j.isdigit():
         
if int(j) < 51:
           
break
    else
:
        K.append(i[
0])
print(K)
for i in range(len(L)):
   
for j in range(4):
       
if L[i][j].isdigit():
            L[i][j] =
int(L[i][j])
       
print(L[i][j], end=' ')
   
print()
SOLUTION:
['mateja', 'nikolina', 'nikola']

momir
67 58 49
mateja 65 88 92
nikolina 89 56 73
sasa 78 25 69
radisa 92 50 69
nikola 67 78 90
ratko 45 69 89

Коментари

Популарни постови са овог блога

Python Fan functions

Python StopWatch milliseconds

Python Accounting