if I have this code that fetch 5 top news and I want it to show up to the user, I try this but it returned an exception and just fetch one line.
def run(self, dispatcher, tracker, domain):
main_url = "https://newsapi.org/v2/top-headlines?sources=techcrunch&apiKey=""
open_page = requests.get(main_url).json()
article = open_page["articles"]
totalResults = []
for ar in article:
totalResults.append(ar["title"])
for i in range(len(totalResults)):
if i == 5:
break
response = (i + 1, totalResults[i])
dispatcher.utter_custom_message(response)
return []