I\'m having issues creating a table that is dynamic to adjust to various results.
I\'ve written a screen scraper to pull stocks from http://finance.yahoo.com and pri
You want to set the width based on the longest item in the column.
In Python, you use max
to find the largest of some group of things. So, outside the loop, you can do:
names_width = max(len(name) for name in namesList)
stock_width = max(len(stock) for stock in stockList)
Then, format each line like you said you tried:
print({0:{3}} {1:{4}} {2}.format(namesList[i],
capital,
price[i],
names_width,
stock_width))