/
rnekrasov
/
Python
Обзор
Документация
Войти
/
rnekrasov
/
Python
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
master
CountMillionCharacters-2.0.py
26 строк
589 B
slowy07
refactor: clean code
30 янв 2022, 04:33
30 янв 2022, 04:33
f0af0c4
Код
Авторство
О чём код?
"""Get the number of each character in any given text. Inputs: A txt file -- You will be asked for an input file. Simply input the name of the txt file in which you have the desired text. """ import collections import pprint def main(): file_input = input("File Name: ") try: with open(file_input, "r") as info: count = collections.Counter(info.read().upper()) except FileNotFoundError: print("Please enter a valid file name.") main() value = pprint.pformat(count) print(value) exit() if __name__ == "__main__": main()