Answer the question
In order to leave comments, you need to log in
How to write data to file once?
Hello!
I execute the following code:
import random
import string
def ipass_generator():
pwd = string.ascii_letters + string.digits + string.punctuation
return "".join(random.choice(pwd) for x in range(random.randint(14, 24)))
passwords = (ipass_generator())
print(passwords)
with open('passwords.txt', 'w') as f:
for password in passwords[:-1]:
f.write(f'{passwords}\n')
f.write(passwords[-1])
Answer the question
In order to leave comments, you need to log in
so what?
...
with open('passwords.txt', 'w') as f:
f.write(passwords)
# конец файла
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question