input: Write a function to read the contents from a given URL and return the content as a string if the request is successful. If the request is not successful, return None.
  
  assert read_url('https://www.example.com')=='<!doctype html>\n<html>\n<head>\n<title>Example Domain</title>\n<meta charset="utf-8" />\n<meta http-equiv="Content-type" content="text/html; charset=utf-8" />\n<meta name="viewport" content="width=device-width, initial-scale=1" />\n<style type="text/css">\nbody {\n    background-color: #f0f0f2;\n    margin: 0;\n    padding: 0;\n    font-family: -apple-system, system-ui, BlinkMacSystemFont, "Segoe UI", "Open Sans", "Helvetica Neue", Helvetica, Arial, sans-serif;\n    \n}\n</style>\n</head>\n<body>\n<div>\n<h1>Example Domain</h1>\n<p>This domain is for use in illustrative examples in documents. You may use this\n    domain in literature without prior coordination or asking for permission.</p>\n<p><a href="https://www.iana.org/domains/example">More information...</a></p>\n</div>\n</body>\n</html>\n'
  assert read_url('http://invalidurl.doesnotexist')==None
output: 
  import requests
  
  def read_url(url):
      try:
          response = requests.get(url)
          response.raise_for_status()
          return response.text
      except requests.RequestException:
          return None
  