Python - Printing on Same Line
Question: I am very new and attempting to learn how to scrape tables. I have the
following code, but can not get the two variables to print on the same line;
they print on separate lines. What am I missing?

    
    
    from lxml import html
    from bs4 import BeautifulSoup
    import requests
    
    url = "http://www.columbia.edu/~fdc/sample.html"
    
    r = requests.get(url)
    
    soup = BeautifulSoup(r.content)
    
    tables = soup.findAll('table')
    
    for table in tables:
        Second_row_first_column = table.findAll('tr')[1].findAll('td')[0].text
        Second_row_second_column = table.findAll('tr')[1].findAll('td')[1].text
        print Second_row_first_column + Second_row_second_column
    


Answer: The columns have a newline at the end, so if you want to print it without
them, you have to
[`.strip()`](https://docs.python.org/2/library/string.html#string.strip) them:

    
    
    print Second_row_first_column.strip() + Second_row_second_column.strip()
    

If you want a space between the two columns, replace the plus with a comma.

