input: Write a python function to group words by their lengths.
  assert groupByLength(['cat', 'dog', 'apple']) == {3: ['cat', 'dog'], 5: ['apple']}
  assert groupByLength(['a', 'aa', 'aaa', 'aaaa']) == {1: ['a'], 2: ['aa'], 3: ['aaa'], 4: ['aaaa']}
  assert groupByLength(['hello', 'world', 'hi']) == {5: ['hello', 'world'], 2: ['hi']}
output: def groupByLength(words):
      result = {}
      for word in words:
          length = word.length()
          if length not in result:
              result[length] = []
          result[length].append(word)
      return result