input: Write a function to find the smallest number in a given list. The function should iterate through the list, compare each element with the current smallest number, and update the smallest number if a smaller one is found. The function should return the smallest number found.
  
  def smallestNumber(nums):
      if not nums:
          return None
      smallest = nums[0]
      for i in range(1, len(nums)):
          if nums[i] < smallest:
              smallest = nums[i]
      return smallest
  
  assert smallestNumber([4, 5, 6, 7, 8])==4
  assert smallestNumber([8, 5, 3, 1, 9])==1
  assert smallestNumber([10])==10
  assert smallestNumber([2, 2, 2, 2])==2
  assert smallestNumber([])==None
output: def smallestNumber(nums):
      if not nums:
          return None
      smallest = nums[0]
      for i in range(1, len(nums)):
          if nums[i] < smallest:
              smallest = nums[i]
      return smallest