Count Letters In String Python Code Example


Example 1: count characters in string python

>>> sentence = 'Mary had a little lamb' >>> sentence.count('a') 4

Example 2: check how many letters in a string python

#use the built in function len()  len("hello")  #or you can count the characters in a string variable  a = "word" len(a)

Comments

Popular posts from this blog

Converting A String To Int In Groovy

"Cannot Create Cache Directory /home//.composer/cache/repo/https---packagist.org/, Or Directory Is Not Writable. Proceeding Without Cache"

Android How Can I Convert A String To A Editable