How to extract odd length words from string in Python

1 Answer

0 votes
s = 'python php java c c++ javascript nodejs vbnet'
   
result = [e for e in s.split() if len(e) % 2] 
 
print(result)  
 
          
       
'''
run:
 
['php', 'c', 'c++', 'vbnet']
       
'''

 



answered Apr 25, 2020 by avibootz
edited Apr 25, 2020 by avibootz

Related questions

1 answer 174 views
1 answer 139 views
1 answer 174 views
1 answer 116 views
1 answer 179 views
...