M
M
MarkPro1002021-12-25 20:58:17
Python
MarkPro100, 2021-12-25 20:58:17

Is the text overlaying itself?

When I load lines in txt, they overlap each other, because of this, only the last password is displayed in txt Question, how can I make sure that each option that is generated by the program is in a separate line Thank you in advance for your answer!

A = "0123456789QWERTYUIOPASDFGHJKLZXCVBNM1234567890-=\.,/qwertyuiopasdfghjklzxcvbnm,.;["
base = len(A)
n = 0
l = 0

while True:
  password = ""
  temp = n
  while len(password) < 1:
    rest = temp % 82
    temp =temp // 82
    password = A[rest] + password
  print(n, password)
  F = open("txt","w")
  for i in password:
    F.write(str(n)+ password + '\n')
    F.close
  
  
  if password == A[-1]*1:
    l += 1
    n = 0

  else:
    n += 1
    time.sleep(1)

Answer the question

In order to leave comments, you need to log in

2 answer(s)
S
soremix, 2021-12-25
@MarkPro100

Open the file in write mode - all previous content is deleted. "a" mode suits you

V
Vindicar, 2021-12-26
@Vindicar

I'll add that
F.close
does absolutely nothing because you don't call the close method.
Should be
F.close()
Better yet, replace this:

F = open("txt","w")
  for i in password:
    F.write(str(n)+ password + '\n')
    F.close

On this
with open("txt","w") as F:
    for i in password:
      F.write(str(n)+ password + '\n')

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question