How to to compare numbers in a list, to the average of all the numbers in the same list. :     import random

    def average():
     infile = open("pa8_numbers.py")
    global mylist
    mylist = []
    num = infile.readline()
    while num != "":
        mylist.append(eval(num))
        
        num = infile.readline()

    Sum = 0
    
    for x in mylist:
        Sum = x + Sum
    global avg
        
    avg = Sum/10000
    
    print("Average: ", end=''), print(format(avg, '.2f'))

These I don't know about, I know it's having trouble getting 'avg' and 'mylist' from of def, but I'm really bad at object oriented programming. Is there a work around?
    
    def above(mylist, avg):
        acount = 0
    
        abv = avg + 10
    
        for a in mylist:
            if a in range(eval(avg, abv)):
                count = count + 1
        print(acount)

    def below(mylist, avg):
        bcount = 0
        blw = avg - 10
    
        for a in mylist:
            if a in range(avg, blw):
                count = count + 1
        print(bcount)

    def main():
    
        outfile = open("pa8_numbers.py","w") 

        for i in range(10000):

            data = random.randint(1,100)

            outfile.write(str(data)+"\n") 

        outfile.close()

        print("Statistics")
        print("---------------------")

    
        average()

        above(mylist, avg)

        below(mylist, avg)

    
    main()

The goal is to make a list of 100 random numbers, sum those numbers and find the avg. The compare the list of random numbers to the avg+10 and avg-10. 

And Count how many random number from the list fall in the category avg+10 and avg-10. 

Please help, thanks
