import math def stats(lista): if not lista: #lista is empty return 0,0 mean = 0 var = 0 for element in lista: mean += element for element in lista: var += (element-mean)**2 return mean/len(lista), math.sqrt(var/len(lista)) def minus(string1, string2): my_set = set(string1) my_other = set(string2) return "".join(my_set - my_other) def count(filename): with open(filename) as infile: count_line = 0 count_word = 0 count_char = 0 for line in infile: count_line +=1 line = line.strip() count_word += len(line.split()) count_char += len(line) return count_line, count_word, count_char def pretty_print(): filename = input("Enter the name of a file: ") cl, cw, cc = count(filename) print( "There are {} lines, {} words, and {} characters in the file {}.".format( cl, cw, cc, filename)) return