I am working on homework and have tried many variations of this code but MyProgrammingLab
doesn’t seem to accept any of them. I am told it needs an “if statement” but I am so burnt out and not really sure where it should go at this point.
The question is this:
Write a program that reads the records from the golf.txt file written in Exercise
10a and prints them in the following format:
This is what I have
def main(): data = open('golf.txt', 'r') name = data.readline() name = name.rstrip('\n') score = '' while name !='': score = data.readline() print('Name:', name) print('Score:', score) name = data.readline() name = name.rstrip('\n') data.close() main()