def eCount (s):
"""Count the e's in a string, using for loop.
Params: s (string)
Returns: (int) #e in s, either lowercase or uppercase
"""
# INSERT YOUR CODE HERE, replacing 'pass'
教授は上記の変更を求めません。 私が達成しようとしている:Pythonのforループを使用して文字列内の文字(大文字と小文字の両方)をカウントします。
count = 0
for e in s:
count +=1
return count
それが与える:
(executing lines 1 to 17 of "e_count_103.py")
15
'sの中の電子のために:'あなたはそれがないと思う何をしません。それぞれの反復で 'e'の値を表示してみてください。また、あなたは実際に質問していません。 – roganjosh
'return s.lower()。count( 'e')'または 'return s.upper()。count( 'E')'これを試してください –