example:
input:
" itspythonand"
output:
p=input() #taking string input from user
s=set(p) #set is a collection of unique elements
d={} #an empty dictionary
for i in s:
c=0
for j in range(len(p)):
if i==p[j]:
c+=1
d[i]=c
print(d)
s=set(p) #set is a collection of unique elements
d={} #an empty dictionary
for i in s:
c=0
for j in range(len(p)):
if i==p[j]:
c+=1
d[i]=c
print(d)
Comments
Post a Comment