I've got 2 files. File 1 has a function and within it, a list. I'm trying to print the contents of that list in File2, however, I'm getting name errors?
Below is File1 where the function is kept, the list I'm trying to access in file 2 is called product.
def news_articles():
search_metric = {
"q": "covid",
"apiKey": "d5da78e207f94fdc8eecd3530acf4edb"
}
base_url = "https://newsapi.org/v2/everything?"
# fetching data in json format
res = requests.get(base_url, params=search_metric)
open_news = res.json()
# getting all articles in a string article
article = open_news["articles"]
# empty list which will
# contain all trending news
global product
product = []
for s in article:
product.append(s["title"])
In file2, I'm just trying to import the module and print(product)