title: Beautiful Soup remove blank lines and blank space
body: <p>I have tried looking for a solution on this site and the web and the google group for beautiful soup with no luck. I believe the problem is I am trying to run functions on empty data names. I just want to remove the blank lines and the empty space around the data coming out of the webpage. Thank you for any help.</p>
  
  <p>Here is my code:</p>
  
  <pre><code>import requests
  from bs4 import BeautifulSoup
  from django.core.management.base import BaseCommand, CommandError
  
  class Command(BaseCommand):
    help = 'Pull Data from RR web'
  
    def handle(self, *args, **options):
      page = requests.get('https://www.radioreference.com/apps/db/?sid=201&amp;opt=all_tg#tgs')
      soup = BeautifulSoup(page.text, 'html.parser')
      rr_name_list = soup.find(class_='titlebox')
      rr_name_list_items = rr_name_list.find_all('td')
  
      for rr_name in rr_name_list_items:
        names = rr_name.contents[0].strip()
        print "".join(line for line in names if not line.isspace()
        print(names)
  </code></pre>
  
  <p>Here is my Error:</p>
  
  <pre><code>NameError: name 'NavigableString' is not defined
  print "".join(line for line in names if not line.isspace())
  ^
  SyntaxError: invalid syntax
  </code></pre>