How to find 3 letter words in a string with Python

1 Answer

0 votes
s = "python java c++ php vb net"
 
words = [word for word in s.split() if len(word) == 3]
 
print(words)
 
 
 
'''
run:
 
['c++', 'php', 'net']
 
'''

 



answered Jul 18, 2019 by avibootz
...