0
How to count blank spaces and alphabets in a string in python?
3 ответов
+ 1
For space Check using isspace() and for alphabet check using isalpha()
+ 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/
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