Counting a's (3) X55221


Statement
 

pdf   zip

Write a function @count_a(s, stop)@ that given a string @s@ and a character @stop@ returns the number of times that letter @a@ occurs in @s@ before the first appearance of character @stop@. If character @stop@ is not in @s@, the function must return 1-1.

Sample session

Sample session
>>> count_a('naturally', 'u')
1
>>> count_a('russian', 't')
-1
>>> count_a('adaptation', 'a')
0
>>> count_a('adaptation', 'n')
3
Information
Author
ProAl
Language
English
Official solutions
Python
User solutions
Python