'none' output for list



So I ported the exercise into PyCharm to see if I could do it on my own. I'm satisfied with the result expect that in the output I'm always getting an annoying 'none' after the list of scores in my list, like so:

Enter the scores separated by a space, please:123 3 4
Your list of scores you put it is:
The average is:
The variance is:
The standard deviation is:

My question is; why is that none there and how do I get rid of it? that would make my output a lot more legible. Thank you in advance.

s = input("Enter the scores separated by a space, please:")
numbers = list(map(int, s.split()))

def print_list(num):
    for n in num:
        print (n)
print ("Your list of scores you put in is:")
print (print_list(numbers))

def sum_numbers(num):
    sum = 0.0
    for n in num:
        sum += n
    return sum

def average_numbers(num):
    sum = sum_numbers(numbers)
    average = round(sum / len(numbers), 2)
    return average
print ('The average is:')
print (average_numbers(numbers))

def variance_numbers(num):
    average = average_numbers(num)
    sum_score = 0.0
    for n in num:
        sum_score += (n - average) ** 2
    variance = round(sum_score / (len(num)-1), 2)
    return variance
print ('The variance is:')
print (variance_numbers(numbers))

def std_numbers(num):
    variance = variance_numbers(num)
    std = round(variance ** 0.5, 2)
    return std
print ('The standard deviation is:')
print (std_numbers(numbers))



print (print_list(numbers))

you use print on the function call, but print_list doesn't return anything? So the default (None) is returned

simply get rid of the print at the function call, so what the function returns isn't printed


Oh, yes, that makes sense. Thank you so much! :slight_smile:


This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.