Skip to Main Content
Blog

Count All Characters in a String in Python

Count All Characters in a String in Python

def main():
	"""
	Counts the number of non-overlapping occurrences of a substring in a string.
	"""

	txt = input("Enter string: ").lower()
	key = input("Enter key: ").lower()
	ctr = txt.count(key)
	print(ctr)


if __name__ == "__main__":
	main()