import math


def linear_search(lst, value):
  for i, v in enumerate(lst):
    if v == value:
      return i
  return -1


def linear_search_v3(lst, value):
  lst.append(value)
  i = 0
  while lst[i] != value:
    i += 1
  lst.pop()
  if i == len(lst):
    return -1
  else:
    return i


# `linear_search_v3` is broken because there is no guarantee `==` is reflexive
list = [1, 2, 3, 4]
print(linear_search(list, math.nan))
print(linear_search_v3(list, math.nan))
