I am using Wiki scraper to search for every word of text in a text file and append the article through the dataframe. I can do this manually but I want it to run through a for loop. Here is what i have:
import requests
import wikipedia
text = list('boy', 'dog', 'service', 'navy')
df = []
for x in text():
wiki = wikipedia.page(x)
df.append(wiki.content)
That gives me a type error though TypeError: 'list' object is not callable
list
is a built-in python method. Notice how it is being highlighted in orange. You can utilize list
in the same way you created the desired list above (shown below). Your for loop is not working because you are calling the method rather than your list.
test_list = list('boy', 'dog', 'service', 'navy')
for x in test_list:
do_thing()
Thus:
list('boy', 'dog', 'service', 'navy')
is the same as ['boy', 'dog', 'service', 'navy']
and list()
is the same as any basic function.