Position X28180


Statement
 

pdf   zip   main.py

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

Sample session

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
InfBesos
Original language
Spanish
Other languages
Catalan Spanish
Official solutions
Python
User solutions
Python