#!/usr/bin/python3 # -*- coding: utf-8 -*- from typing import Optional def linear_search(numbers: list[int], key: int) -> Optional[int]: for i, number in enumerate(numbers): if number == key: return i return None def main() -> None: numbers: list[int] = [2, 4, 7, 10, 11, 32, 45, 87] print("NUMBERS: ", numbers) key = int(input("Enter a value: ")) # This takes O(n) keyIndex = linear_search(numbers, key) if keyIndex is None: print(key, " was not found") else: print("Found ", key, " at index ", keyIndex) if __name__ == "__main__": main()