For a homework assignment, I am suppose to implement a function numLen()
that takes a string s
and an integer n
as parameters, and returns the number of words in the string s
that have length n
. Words in the string are non-space characters separated by at least one space.
an example would be to input:
>>> numLen("This is a test", 4)
and get 2 because there are 2 words in the string that have 4 characters.
I have no clue how to do this.