Exercise 4: Linear Search Through a Tuple — Possible Solution ==================================================================== colours = ("red", "green", "blue", "yellow", "purple") target = input("Enter a colour to search for: ") index = 0 found_at = -1 while index < len(colours): if colours[index] == target: found_at = index break index += 1 if found_at == -1: print("Not found") else: print(f"Found at index {found_at}") Example run (target = "blue"): Found at index 2 Example run (target = "orange"): Not found WHY THIS WORKS AS AN ANSWER ------------------------------ found_at starts at -1, a value that can never be a genuine index, so it doubles as both "not found yet" and, at the end, "never found at all." This avoids the tempting-but-wrong shortcut of checking "if found_at:" as a boolean — index 0 is a perfectly valid match, but 0 is falsy in Python, so a naive truthiness check would incorrectly treat "found at index 0" the same as "not found." Comparing explicitly against -1 sidesteps that trap entirely. break exits the loop the moment a match is found, so the search doesn't keep scanning colours that come after the match — the same early-exit principle used in the lesson's case study and in Exercise 6.