I know A lot of people ask about that but I tried a lot of method and none of it work for me.
I'm writing random string generator using python but when I save it to text file it only contains the last line.
But in command line its print all lines.
This is my code.
import sys
import random
ch = 'ZXCVBNM<>?":LKJHGFDSAQWERTYUIOP{}|+_)(*&^%$#@!~zxcvbnm,./;lkjhgfdsapoiuytrewq`1234567890'
nop = input('How Many password do you want to create?')
nop = int(nop)
lop = input('Whats the length of passwords?')
lop = int(lop)
for p in range (nop):
password = ''
for l in range(lop):
password += random.choice(ch)
print(password)
pwd = open("pwd.txt", "w")
pwd.write(password)
pwd.close()