我對我手動輸入的字符串的計數有點困惑。我基本上是在計算沒有空格的字數和字符數。另外如果可能的話,誰可以幫助計算元音?計算一個字符串python
這是我到目前爲止有:
vowels = [ 'a','e','i','o','u','A','E','I','O','U']
constants= ['b','c','d','f','g','h','j','k','l','m','n','p','q','r','s','t','v','w','x','y','z']
s= input ('Enter a Sentence: ')
print ('Your sentence is:', s)
print ('Number of Characters', len(s));
print ('Number of Vowels', s);
這有助於http://stackoverflow.com/questions/20226110 /檢測元音-vs-consonants-in-python – neiesc 2014-10-29 23:32:21