input: Write a function to find and return the longest string from a given list of strings. If the list is empty, return None. If there are multiple strings with the same longest length, return the first one encountered.
  assert longest_string(['foo', 'test', 'longstring', 'bar'])=='longstring'
  assert longest_string(['short', 'longer', 'longest'])=='longest'
  assert longest_string(['a', 'b', 'c'])=='a'
  assert longest_string([])==None
  assert longest_string(['same', 'size'])=='same'
output: def longest_string(strings):
      if not strings:
          return None
      longest = strings[0]
      for s in strings:
          if len(s) > len(longest):
              longest = s
      return longest