【发布时间】:2018-01-27 20:48:09
【问题描述】:
import sys
x=input("Enter the string") `# getting the input#`
i=1
ctr=0
print(len(x)) #printing the length of the whole line
while(i<=len(x)):
if(x[i]=='a'):
ctr=ctr+1
i=int(i+1)
print(ctr)
【问题讨论】:
-
请在您的问题中添加更多信息,说明您要达到的目标,以便其他人可以提供帮助。
-
Python 使用从 0 开始的索引,所以你需要
i=0和i<len(x)
标签: python