how can i know the characters count in a word in python code example
Example 1: pyton count number of character in a word
# Count number of characters in a string (word)
a = "some string"
print len(a) # 11
Example 2: Python Program to Count the Occurrences of a Word in a Text File
#get file object reference to the file
file = open("C:\workspace\python\data.txt", "r")
#read content of file to string
data = file.read()
#get number of occurrences of the substring in the string
occurrences = data.count("python")
print('Number of occurrences of the word :', occurrences)