How to count the strings in a list with strings and numbers using Python

1 Answer

0 votes
lst = [2, 99, "java", 34, "c++", 7, "python", "c", 890, "c#", "javascript"] 

total = len(list(i for i in lst if isinstance(i, str))) 
  
print(total)
 
 
 
'''
run:
 
6
 
'''

 



answered Feb 18, 2024 by avibootz
...