-
-
Save bbookman/e5c6030a9e2624bbdb85e1e5e2efa37f to your computer and use it in GitHub Desktop.
| '''Find all of the words in a string that are less than 4 letters''' | |
| sentence = 'On a summer day somner smith went simming in the sun and his red skin stung' | |
| examine = sentence.split() | |
| result = [word for word in examine if len(word) >=4] | |
| print(result) |
sentence = "me myself and my string"
less_than_4 = [word for word in sentence.split(" ") if len(word)<4]
print(less_than_4)
#in the instructions there was stated ,,less than 4 letters"
sorted([(word, len(word)) for word in 'On a summer day somner smith went simming in the sun and his red skin stung'.split() if len(word) < 4], key=lambda x: x[1], reverse=True)str = 'In 1984 there were 13 instances of a protest with over 1000 people attending'
x = [x for x in str.split(' ') if len(x)<4 and not x.isnumeric()]
numbers should be excluded, as they are not words
sentence = 'On a summer day somner smith went simming in the sun and his red skin stung'
words=tuple(sentence.split(' '))
result =[i for i in words if len(i) < 4]
print (result)
I think mine should be shorter the code?
# Find all the words in a string that are less than 4 letters
string = 'all the words in a string'
my_list = [word for word in string.split(' ') if len(word) < 4]
print(my_list)
"""
Find all of the words in a string that are less than 4 letters
"""
words = [i for i in string.split() if len(i) < 4]
sentence = 'On a summer day somner smith went simming in the sun and his red skin stung'
result= [word for word in sentence.split() if len(word)<=4]
print(result)
s = 'On a summer day somner smith went simming in the sun and his red skin stung'
l=[i for i in s.split() if len(i)<4]
hello!
if it's "less" than 4 letters it should be "if len(word) <4" not >=4