Q:

Python TypeError: int() argument must be a string, a bytes-like object or a number, not 'NoneType'

I am a student and am pretty new to python. I am trying to validate the user input to check whether or not they entered a 3 digit number, they should only be able to enter a 2 digit number. The program works fine when the user enters only 2 digits but when they enter 3 or more, it throws the error message I created and asks them to re-enter a number that is only 2 digits, then once they re-enter a 2 digit number python gives me the TypeError. The full error I am getting is: 
Traceback (most recent call last):
  File "/Users/admin/Desktop/week6/question_7.py", line 87, in <module>

  File "/Users/admin/Desktop/week6/question_7.py", line 79, in do_stuff
    print (display_grade(user_in))
TypeError: int() argument must be a string, a bytes-like object or a 
number, not 'NoneType'

I am having trouble figuring out why it is doing this. I have a feeling it has something to do with the calling the get_input() function inside of itself? I can't figure out how to avoid this though. 
I searched the error I keep getting and couldn't find anything that helped. 
Here's the program, it's pretty simple. 
 NUMBER_OF_TESTS = 5

def get_input ():
    print ('enter a test score below')
    user_in = input()
    if len(user_in) > 2:
        print ('error, you can only enter a 2 digit number.')
        get_input()
    else:
        return user_in

def display_grade (letter_grade):
    if letter_grade >= 89:
        return ('You got an A!')
    elif letter_grade >= 80 and letter_grade <= 89:
        return ('You got a B!')
    elif letter_grade >= 70 and letter_grade <= 79:
        return ('You got a C')
    elif letter_grade >= 61 and letter_grade <= 69:
        return ('You got a D')
    else:
        return ('You got an F')

def calAverage(total):
    average_score = (total) / NUMBER_OF_TESTS
    return int(average_score)

def do_stuff():
    i = 0

    x = 0

    while i < NUMBER_OF_TESTS:
        user_in = int(get_input())
        print (display_grade(user_in))
        x = x + user_in
        i = i + 1
    print ('your average score is' , calAverage(x) , 'which means' , display_grade(calAverage(x)))

do_stuff()

A:

def get_input ():
    print ('enter a test score below')
    user_in = input()
    if len(user_in) > 2:
        print ('error, you can only enter a 2 digit number.')
        get_input()
    else:
        return user_in

The problem is the recursive get_input() call.  When you make that call, you're not returning the value you get, so None is returned instead.  Replace it with return get_input().  Also, your function doesn't allow for people to get 100 on a test.  I don't know if that's intentional.

