+ 1
guys i m trying to make a program which gives the percentage of each letter in a word...but its not working as expected..
3 Respostas
+ 1
You have stored only capital letters I.e.
Alphabets=['A','B'.....'Z']
And the word you passed in the function call contains small letters also...so you are getting output only for capital letters
+ 1
So for your desired output..
You can convert the string into uppercase..I.e word.upper()
+ 1
Or you can take help of this code
def per(word,letter):
count=0
for i in word:
if i==letter:
count+=1
p=(count/len(word))*100
print( letter,"percentage ",p)
word="pill"
print(word)
for letter in word:
per(word,letter)