How to check if a list has an empty string in Python

2 Answers

0 votes
lst = ['python', 'php', '', 'java'] 

b = any(len(item) == 0 for item in lst) 
  
print(b) 


 
'''
run:
 
True
 
'''

 



answered Jan 17, 2020 by avibootz
0 votes
lst = ['python', 'php', '', 'java'] 

if '' in lst:
  print("yes") 
else:
  print("no") 


 
'''
run:
 
yes
 
'''

 



answered Jan 17, 2020 by avibootz

Related questions

1 answer 162 views
1 answer 165 views
1 answer 159 views
1 answer 108 views
1 answer 208 views
...