#!/usr/bin/env python
# coding: utf-8
# # Count Character Occurrences using Python
# In[5]:
def count_characters(s):
count = {}
for i in s:
if i in count:
count[i] += 1
else:
count[i] = 1
print(count)
word=input("Enter your string:")
count_characters(word)
#clcoding.com
0 Comments:
Post a Comment