The first and last occurrence

The first and last occurrence. Given a string that may or may not contain the letter “f”, print the index location of the first and last appearance of “f”. If the letter “f” occurs only once, print its index. If the letter “f” does not occur, do not print anything. Do not use loops in this task.

Test Case Input (String) Expected Output
1 find the function 0
2 coffee 2
3 alphabet