input: Write a function that eliminates lowercase segments from an input string.
  assert remove_lowercase_segments("PYTHon") == 'PYTH'
  assert remove_lowercase_segments("FInD") == 'FID'
  assert remove_lowercase_segments("STRinG") == 'STRG'
output: def remove_lowercase_segments(s):
      result = []
      segment = []
      
      def flush_segment():
          nonlocal segment
          if not segment or segment[0].isupper():
              result.extend(segment)
          segment = []
      
      for char in s:
          if char.islower():
              flush_segment()
              segment.append(char)
          else:
              segment.append(char)
      
      flush_segment()
      return ''.join(result)