input: Write a python function to parse a JSON string and access nested data.
  assert parse_and_access_json('{"name": "John","age": 30,"address": {"city": "New York","state": "NY"}}', 'name') == 'John'
  assert parse_and_access_json('{"name": "John","age": 30,"address": {"city": "New York","state": "NY"}}', 'age') == 30
  assert parse_and_access_json('{"name": "John","age": 30,"address": {"city": "New York","state": "NY"}}', 'address.city') == 'New York'
output: import json
  
  def parse_and_access_json(json_string, key):
      data = json.loads(json_string)
      keys = key.split('.')
      for k in keys:
          data = data[k]
      return data