0

How to count blank spaces and alphabets in a string in python?

30th Apr 2020, 1:05 PM
Suhani Sharma
3 Answers
+ 1
For space Check using isspace() and for alphabet check using isalpha()
30th Apr 2020, 2:26 PM
ANJALI SAHU
+ 5
There is method called count. strings = "Hello world" print(strings.count("l")) output : 3 a_list = [1,2,3,2,3,14,] print(a_list.count(3)) print(a_list.count(14) output : 2 1 for more, visit--> https://docs.python.org/3/
30th Apr 2020, 1:08 PM
M Tamim
M Tamim - avatar
0
If you are talking about a string , let's say "Hello world" simply assign a variable count=0 run a for loop for i in string If i==" ": count+=1 For alphabets you can use If i.isAplha method
30th Apr 2020, 1:10 PM
Abhay
Abhay - avatar