M
M
MarkPro1002021-12-26 10:48:12
Python
MarkPro100, 2021-12-26 10:48:12

Does he write an extra letter?

The whole essence of the problem is in the screenshot. The program writes extra numbers in txt, although everything is fine in the console, thanks to Sarina for the answer!
61c81dd7504c4932944782.png

import time
A = "0123456789QWERTYUIOPASDFGHJKLZXCVBNM-=\.,/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","a")
  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
S1riyS, 2021-12-26
@MarkPro100

You need to replace the line print(n, password)withprint(password)

V
Vindicar, 2021-12-26
@Vindicar

Why do you need a for i in password: loop at all?
If you need to output the same thing to the console and to the file, then execute F.write(f'{n} {password}\n') and that's it.
Well, the trick with with, which I showed in your previous question, should also be applied.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question