I was doing a codewars challenge where you had to find the smallest wird on a string and i decided to use the len() function but whenever ran the code it gave me the following error:
Traceback (most recent call last):
File "main.py", line 4, in <module>
test.assert_equals(find_short("bitcoin take over the world maybe who knows perhaps"), 3)
File "/home/codewarrior/solution.py", line 5, in find_short
if word.len() < l:
AttributeError: 'str' object has no attribute 'len'
here is the defective code, i really can't find what is wrong with it:
def find_short(s):
foo = s.split()
l = 100
for word in foo:
if word.len() < l:
l = word.len()
else:
continue
return l # l: shortest word length