I can't write homoglyphs output to text file

Question:

I’m trying to create a homoglyph text based on the word web, but it doesn’t seem to write the output inside the text. I tried to do this based on this site https://pypi.org/project/homoglyphs/

import homoglyphs as hg

homoglyph = open("dictionaries/homoglyphs.txt", 'w', encoding="utf-8")

random = hg.Homoglyphs().get_combinations('web')
homoglyph.write(random +'n')

It won’t let me put the homoglyph into the .txt file. Did I miss some steps before I can output the word into the text?

EDIT:
I think i’m going to put this question aside since the output of the homoglyph is not what i wanted for a project.

Thanks for the help guys!

Asked By: Tsukuru

||

Answers:

Like the error message tells you, you have a list of strings, adding 'n' to a list is not well-defined.

with open("dictionaries/homoglyphs.txt", 'w', encoding="utf-8") as homoglyph:
    random = hg.Homoglyphs().get_combinations('web')
    for item in random:
        homoglyph.write(item + 'n')

Your variable names might need some thinking, there’s nothing "random" about the list of homoglyphs (except perhaps how they are ordered).

Answered By: tripleee