Answers for "count characters a string in python"

10

count characters in string python

>>> sentence = 'Mary had a little lamb'
>>> sentence.count('a')
4
Posted by: Guest on December-30-2020
0

count characters in string python

# count the number of characters in a string:
len("The quick brown fox jumps over the lazy dog")
# OUTPUT: 43

# count the number of character OCCURENCES in a string:
string = "The quick brown fox jumps over the lazy dog"
string.count(" ")
# OUTPUT: 8
Posted by: Guest on March-29-2022

Code answers related to "count characters a string in python"

Python Answers by Framework

Browse Popular Code Answers by Language