When i run the code below, i get three lists, one below the other vertically. I want them to be horizontal, separated by a comma (similar to the last print list statement, where the data is separated by a comma). I tried rearranging the for loop statements, and I get all sorts of combinations, but nothing like I wanted that I described above. Please help!
import bs4 as bs
import urllib.request
import re
sauce = urllib.request.urlopen('http://www5.statcan.gc.ca/cimt-cicm/topNCountryCommodities-marchandises?lang=eng&chapterId=27§ionId=0&refMonth=2&refYr=2017&freq=6&countryId=999&usaState=0&provId=1&arrayId=9900000&commodityId=271111&commodityName=Natural+gas%2C+liquefied&topNDefault=10&tradeType=3').read()
soup = bs.BeautifulSoup(sauce,'lxml')
regexQ = re.compile('.*Date1 Qty.*')
regexC = re.compile('.*Footnote.*')
regexV = re.compile('.*Date1 Val.*')
for countryPart in soup.findAll("a",{"href":regexC}):
Country = countryPart.text.strip()
print(Country)
for DatePart in soup.findAll("td",{"headers":regexQ}):
Quantity = DatePart.text.strip()
print(Quantity)
for ValPart in soup.findAll("td",{"headers": regexV}):
Value = ValPart.text.strip()
print(Value)
list = [Country,Quantity,Value]
print(list)