16 lines
447 B
Python
16 lines
447 B
Python
number_of_lines = lambda filename: len(open(filename, 'r').readlines())
|
|
|
|
|
|
def number_frequency(filename):
|
|
result = {}
|
|
for number in open(filename, 'r').read().splitlines():
|
|
if not number in result: result[number] = 0
|
|
result[number] += 1
|
|
return result
|
|
|
|
|
|
if __name__ == "__main__":
|
|
print(number_of_lines('numbers.txt'))
|
|
frequencies = number_frequency('numbers.txt')
|
|
for key in frequencies:
|
|
print(f'{key}: {frequencies[key]}') |