DATE: 03-12-2017
Q) Count Words of Minimum Length L
Given a string S, which contains several words, print the count C of the words whose length is atleast L. (You can include punctuation marks like comma, full stop also as part of the word length. Space alone must be ignored)Input Format:
The first line contains S.
The second line contains L.Output Format:
The first line contains CBoundary Conditions:
2 <= Length of S <= 1000Example Input/Output 1:
Input:
During and after Kenyattas inauguration police elsewhere in the capital, Nairobi, tried to stop the opposition from holding peaceful demonstrations.
5Output:
13Explanation:
The words of minimum length 5 are
During
after
Kenyattas
inauguration
police
elsewhere
capital,
Nairobi,
tried
opposition
holding
peaceful
demonstrations
The first line contains S.
The second line contains L.
The first line contains C
2 <= Length of S <= 1000
Input:
During and after Kenyattas inauguration police elsewhere in the capital, Nairobi, tried to stop the opposition from holding peaceful demonstrations.
5
13
The words of minimum length 5 are
During
after
Kenyattas
inauguration
police
elsewhere
capital,
Nairobi,
tried
opposition
holding
peaceful
demonstrations
sol:-
PYTHON3-CODE:
s=input().split()
n=int(input())
a=[]
for i in s:
if(len(i)>=n):
a.append(i)
print(len(a))
n=int(input())
a=[]
for i in s:
if(len(i)>=n):
a.append(i)
print(len(a))
0 Comments