python-examples icon indicating copy to clipboard operation
python-examples copied to clipboard

String: Basic Methods

Open Deepakkr07-cyber opened this issue 4 years ago • 1 comments

Q. Given a string as input. Count number of a's in the string?

Input : "abacd"

Output : 2

Deepakkr07-cyber avatar Mar 22 '21 17:03 Deepakkr07-cyber

st="abacd" len1=len(st) count=0

for i in range (0,len1): ch=st[i]

         if(ch=='a') :
                 count= count+1

Print(count)

Deepakkr07-cyber avatar Mar 22 '21 17:03 Deepakkr07-cyber