input: Write a python function to convert a number into words.
  assert num2words(213) == "two hundred thirteen "
  assert num2words(999) == "nine hundred ninety nine "
  assert num2words(40) == "forty "
output: def num2words(num):
      if num == 0:
          return "zero "
      
      under_20 = ['zero', 'one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight', 'nine', 'ten', 
                  'eleven', 'twelve', 'thirteen', 'fourteen', 'fifteen', 'sixteen', 'seventeen', 'eighteen', 'nineteen']
      tens = ['', '', 'twenty', 'thirty', 'forty', 'fifty', 'sixty', 'seventy', 'eighty', 'ninety']
      
      def words(n):
          if n < 20:
              return under_20[n]
          elif n < 100:
              return tens[n // 10] + ('' if n % 10 == 0 else ' ' + under_20[n % 10])
          elif n < 1000:
              return under_20[n // 100] + ' hundred' + ('' if n % 100 == 0 else ' ' + words(n % 100))
          else:
              raise ValueError("This function supports numbers less than 1000 only.")
      
      return words(num) + ' '