Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

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
Source by discuss.codecademy.com #
 
PREVIOUS NEXT
Tagged: #count #characters #string #python
ADD COMMENT
Topic
Name
6+4 =