I am trying to find the number of times in a list a word is equal to a set length? So for the example: 'my name is ryan' and 2 the function would give me back 2 as the number of times a word has a length of 2. I have:
def LEN(a,b):
'str,int==>int'
'returns the number of words that have a len of b'
c=a.split()
res=0
for i in c:
if len(i)==b:
res=res+1
return(res)
But all this gives me is a res of 1 and doesn't go past the first i with a len of c.