Position X28180


Statement
 

pdf   zip

thehtml

Write a function @pos_a(s, k)@ that takes a string s and a non-negative integer k and returns the position where the k-th letter a occurs within s, or -1 if the string s contains fewer than k letters a.

Sample session
>>> pos_a('', 1)
-1
>>> pos_a('hola', 2)
-1
>>> pos_a('ara', 3)
-1
>>> pos_a('lalaland', 3)
5
>>> pos_a('almendro', 1)
0
Information
Author
InfBesos
Language
English
Translator
Original language
Catalan
Other languages
Catalan Spanish
Official solutions
Python
User solutions
Python