0

How can we count the 'alphabets' in a string

23rd Feb 2020, 4:03 PM
Taraash Mittal
Taraash Mittal - avatar
9 Respostas
23rd Feb 2020, 4:12 PM
David Ashton
David Ashton - avatar
+ 5
dunno about other codes here but it looks a bit dirty or overly complex. here's my implementation string = "abracadabra" length = len([i for i in string if i.isalpha()]) print(length)
24th Feb 2020, 4:14 PM
Shen Bapiro
Shen Bapiro - avatar
+ 1
Thanks mirielle, that's exactly what I needed
23rd Feb 2020, 4:18 PM
Taraash Mittal
Taraash Mittal - avatar
+ 1
Thanks EVERYONE for your help, I will never forget it😃😃
23rd Feb 2020, 4:22 PM
Taraash Mittal
Taraash Mittal - avatar
0
Can you please explain it with an example?
23rd Feb 2020, 4:08 PM
Taraash Mittal
Taraash Mittal - avatar
0
What I am trying to ask is, so suppose X=['anystring'] Print(number of alphabets in it) In this case the alphabets are 9
23rd Feb 2020, 4:12 PM
Taraash Mittal
Taraash Mittal - avatar
0
Similar, I want 5+2+2+1+1 in Abracadabra, the total alphabets are 11
23rd Feb 2020, 4:14 PM
Taraash Mittal
Taraash Mittal - avatar
0
this is the most simple i can come up with : def count(word): n = len(word) return (n) y = count('rainbowxyz') print(y)
25th Feb 2020, 7:04 PM
Yashshree Patil
Yashshree Patil - avatar
- 1
alpha = "alphabets" count = lenght(alpha) print(count)
25th Feb 2020, 7:11 PM
Enock Arthur
Enock Arthur - avatar