-4
#!/bin/python3

import math
import os
import random
import re
import sys

# Complete the breakingRecords function below.
def breakingRecords(scores):
    
    first_best_record = scores[0]
    first_worst_record = scores[0]
    
    best_record = 0
    worst_record = 0
    
    for score in scores:
        if score > first_best_record:
            first_best_record = score
            best_record += 1
        elif score < first_worst_record:
            first_worst_record = score
            worst_record += 1
            
    print(best_record, worst_record)
        

if __name__ == '__main__':
    fptr = open(os.environ['OUTPUT_PATH'], 'w')

    n = int(input())

    scores = list(map(int, input().rstrip().split()))

    result = breakingRecords(scores)

    fptr.write(' '.join(map(str, result)))
    fptr.write('\n')

    fptr.close()

There we go... Runtime Error!:

Runtime Error

No response in my output:

Output

CryptoFool
  • 21,719
  • 5
  • 26
  • 44
  • 1
    Welcome to Stack Overflow! Please do not include portions of your question, including output and error messages, as screen shots and/or external links. Include the actual text of your output and errors in the body of your question as formatted text. The `{}` code formatting tool works well for this. – CryptoFool Mar 25 '21 at 05:18
  • 1
    I fixed your question to at least include the screen shots inline so that readers can see them as part of the question. This is better, but is not the right thing to do. The right thing is to include the text from these screen shots directly in the question as text. The second screen shot is possibly OK, since it shows the input and expected output. But error messages are really important to a question like this, and should be included as copy/pasteabe text. It would be OK to include the link as well to provide additional information. – CryptoFool Mar 25 '21 at 05:28

1 Answers1

1

Your function breakingRecords does not return a value, and so returns None. So then where you use the result returned by breakingRecords, here:

result = breakingRecords(scores)
fptr.write(' '.join(map(str, result)))

because breakingRecords returns None, result is None. The map function takes an iterator as its second argument. You're passing None for that argument. So you get the error:

TypeError: 'NoneType' object is not iterable

when map tries to iterate over None. The answer here is to have breakingRecords return an iterable for map to work on.

CryptoFool
  • 21,719
  • 5
  • 26
  • 44