def dot_trick(username):
emails = list()
username_length = len(username)
combinations = pow(2, username_length - 1)
padding = "{0:0" + str(username_length - 1) + "b}"
for i in range(0, combinations):
bin = padding.format(i)
full_email = ""
for j in range(0, username_length - 1):
full_email += (username[j]);
if bin[j] == "1":
full_email += "."
full_email += (username[j + 1])
emails.append(full_email + "mars")
return emails
username = ("marsbros")
print(*dot_trick(username) , sep="\n")
I want to get the same result as print
with sep='\n'
and write it to a file line by line.