32 lines
897 B
Python
32 lines
897 B
Python
|
def count():
|
||
|
sentence = "Я пришел, я ушел, я нашел"
|
||
|
str1 = 'Я'
|
||
|
str2 = 'я'
|
||
|
if str1.lower() == str2.lower():
|
||
|
count1 = sentence.count(str1)
|
||
|
count2 = sentence.count(str2)
|
||
|
print("The count of 'Я' is", count1+count2)
|
||
|
|
||
|
sentence2 = sentence.count('пришел')
|
||
|
sentence3 = sentence.count('ушел')
|
||
|
sentence4 = sentence.count('нашел')
|
||
|
|
||
|
|
||
|
print("The count of 'пришел' is", sentence2)
|
||
|
print("The count of 'ушел' is", sentence3)
|
||
|
print("The count of 'нашел' is", sentence4)
|
||
|
|
||
|
count()
|
||
|
|
||
|
# from collections import defaultdict
|
||
|
|
||
|
# test_sentence = ["Я", "пришел", "я", "ушел", "я", "нашел"]
|
||
|
|
||
|
# print("The original sentence is : " + str(test_sentence))
|
||
|
|
||
|
# res = defaultdict(int)
|
||
|
|
||
|
# for count in test_sentence:
|
||
|
# res[count.lower()] += 1
|
||
|
|
||
|
# print("Strings Frequency : " +str(dict(res)))
|