Wirte a program to display the word that are repeated more than or equal to N time in the text
Anonymous User
582

Wirte a program to display the word that are repeated more than or equal to N time in the text;
**Input: 1) first input is a string.

  1. second input is integer (count) representing value of number of times word occure in text.**
str1 = input('enter the string : - ')
n = int(input('Enter the count : - '))
str1= str1.split(' ')
# print(str1)
count = dict()
for word in str1:
    if word in count:
        count[word]+=1
    else: count[word]=1
# print(count)
word_list = []
for key in count:
    if count[key]>= n:
        word_list.append(key)
if len(word_list)>0:
    print(word_list)
else:print('NA') 
Comments (1)