input: Write a function to find and return the longest string from a given list of strings. If there is more than one string with the same maximum length, return the first one encountered.
  assert longest_string(['foo', 'test', 'longstring', 'bar'])=='longstring'
  assert longest_string(['apple', 'banana', 'cherry'])=='banana'
  assert longest_string(['cat', 'dog', 'elephant'])=='elephant'
  assert longest_string([])==None
  assert longest_string(['a', 'bb', 'ccc', 'dddd', 'eeeee'])=='eeeee'
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