this is my code to create a URL link for Yahoo Finance with for a specific company (in this case Microsoft).
index = 'MSFT'
url_is = 'https://finance.yahoo.com/quote/' + index + '/financials?p=' + index
How can i create a for cicle for multiple companies with different tickers (for example index = ['MSFT', 'AAPL', 'V'])
Thanks a lot
Try this:
index = ['MSFT', 'AAPL', 'V']
for company in index:
url_is = 'https://finance.yahoo.com/quote/' + company + '/financials?p=' + company
print(url_is)
If you wanted to store the resulting URLs in a list, just do:
my_list = []
for company in index:
url_is = 'https://finance.yahoo.com/quote/' + company + '/financials?p=' + company
my_list.append(url_is)