How to count strings and integers from a list of strings in Python

1 Answer

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

totalintegers = len(list(i for i in lst if i.isdigit()))
  
print(totalintegers)

totalstrings = len(list(i for i in lst if not i.isdigit() and isinstance(i, str))) 
   
print(totalstrings)
 
 
 
'''
run:
 
5
7
 
'''

 



answered Feb 18, 2024 by avibootz
...