In what concerns the continuous evaluation solving exercises grade during the semester, you should submit until 23:59 of November 9th
(this exercise will still be available for submission after that deadline, but without counting towards your grade)
[to understand the context of this problem, you should read the class #05 exercise sheet]


In this problem you should submit a function as described. Inside the function do not print anything that was not asked!

[IP043] Searching for the treasure

As you marveled at how many challenges you had faced in Wonderland, a group of Curious Oysters suddenly emerged from the sea, quietly shuffling up to you. Their eyes were wide, and their tiny voices spoke in unison, "We’re curious... oh, so curious!"

One particularly brave oyster stepped forward and said, “We’ve heard that you are quite skilled with Python. We love searching for hidden treasures, and we want you to help us find things in tuples. Could you help us search for specific values?"

The Problem

Write a function search(tup, value) that given a tuple tup and a value returns a tuple (first,last), respectively the first and last index position where value appears (indices start with zero, of course). If the value does not appear, return (-1,-1).

For instance the tuple (1,2,1,2,1) has the value 1 in three positions: 0, 2 and 4, so search((1,2,1,2,1),2) should return (0,4), the first and last index.

Constraints

The following limits are guaranteed in all the test cases that will be given to your program:

1 ≤ |tup| ≤ 100       size of the input tuple

Example Function Calls Example Output
print(search( (1,2,1,2,1), 1 ))
print(search( ("a","b","b","c"), "b" ))
print(search( ("a","b","b","c"), "c" ))
print(search( (True, True, True), False ))
(0, 4)
(1, 2)
(3, 3)
(-1, -1)

Introduction to Programming (CC1024)
DCC/FCUP - University of Porto