+ 1

How can we print the no. of repetition of each letter in the given word using Python language?

15th Sep 2019, 7:30 PM
Bikash Chauhan
Bikash Chauhan - avatar
2 Answers
+ 6
You can do it easily: 'yourwordhere'.count('o') Will give you 2 as an answer.
15th Sep 2019, 7:34 PM
Loïc Mahé
Loïc Mahé - avatar
+ 2
s = 0 for letter in word: if(letter==your_letter): s+=1 Or: s = len([None for letter in word if letter==your_letter])
15th Sep 2019, 7:34 PM
Aymane Boukrouh
Aymane Boukrouh - avatar