summaryrefslogtreecommitdiff
path: root/day1/task1/task1.py
blob: 61ab4cfa80dbc68207b81ffef1219e8f16b4ece6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
import os

character = input('Введите один символ: ')
while len(character) > 1:
    character = input('Введите РОВНО один символ: ')


path = os.path.join(os.getcwd(), 'task1_data.txt')
if not os.access(path, os.R_OK):
    print('Файл "{}" не доступен для чтения'.format(path))
else:
    with open(path) as f:
        data = f.read(1024)
        i = data.count(character)
        while data:
            data = f.read(1024)
            i += data.count(character)

        print('В данном файле {} символов "{}"'.format(i, character))