Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def func(file, x):
- with open(file, 'r', encoding='utf-8') as f:
- text = f.read().split(' ')
- proc = 0
- un = []
- un2 = []
- for word in text:
- if word.startswith('un'):
- un.append(word)
- if len(word) > x:
- un2.append(word)
- if len(un) > 0:
- proc = (len(un2) / len(un)) * 100
- print('Слов с приставкой un-: ', len(un))
- print('Процент слов с приставкой un-, длиннее ' + str(x) + ' символов: ', proc)
- func('text.txt', 5)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement