Can someone help...
My driver file is here:
from functions import process_marks
def main():
try:
f = open(argv[1])
except FileNotFoundError:
print("\nFile ", argv[1], "is not available")
exit()
process_marks(f)
f.close()
main()
I'm trying to modify process_marks(f)
to run my code. and produce this (from file that runs without functions):
Names of students who have written tests:
Anthony Austyn Bronson Conor Mark
Enter name of student whose test results you wish to see: Anthony
Summary of Test Results for Anthony
===================================
Test scores: 85 85 85 85
Number of tests written .................. 4
This is what I currently have:
names = []
name_print = "\nSummary of Test Results for "
def process_marks(file_name):
names
for line in file_name:
names.append(line.split()[0])
print('\nNames of students who have written tests:')
print(*sorted(names), sep=' ')
name = input('Enter name of student whose test results '
'you wish to see: ')
check_name(name)
parts = line.split()
if parts[0] == name:
print_scores(name)
def check_name(person):
if person not in names:
print('\nNo test data found for ', person)
input("Press Enter to continue ...")
else:
print(name_print + person)
def print_scores(person, parts):
print('=' * ((len(name_print)) - 1))
test_scores = ' '.join(parts[1:])
print('Test scores: ', end=' ')
print(test_scores)
Which outputs:
Names of students who have written tests:
Anthony Austyn Bronson Conor Mark
Enter name of student whose test results you wish to see: Anthony
Summary of Test Results for Anthony
I need help making print_scores()
function work in process_marks()
.
Can someone see where my errors lie?