I wanted to add extra functionality to wiki-bot by adding a way for it to write to file and print it at the same time so that the user can skip the long wait to copy all the information. My code works with
print
but not with
f = open("output_from_wikibot.txt", "w")
f.write("Page content:\n", content, "\n")
f.write("Page title:", title, "\n")
f.write("Categories:", categories, "\n")
f.write("Links:", links, "\n")
f.write("References:", references, "\n")
f.write("Summary:", summary, "\n")
It gives me the following error:
TypeError: can only concatenate str (not "list") to str
At first I thought "Oh that's easy, just take each one of them and put them in a different line" but of course, it did not work.
I am newbie to Python and Wikipedia API. I have done projects with PRAW, Discord.py, BeautifulSoup4