import random for r in range(15): for i in range(1): # se estivesse 5 mostrava 5 numeros #print(random.randint(1 ,25)) k=random.randint(1, 16) print (k) arq = "bjjj.txt" with open(arq ,'r+') as arquivo: numer = arquivo.readline() if not(str(k)) in numer: print ('não EXISTE') file1 = open('bjjj.txt', 'a+') file1.seek(0) file1.write(' ' + str(k)) file1.close() if (str(k)) in numer: print (' EXISTE') print(k) print(numer, end='')the variable k comes from a random compare with a txt that has inserted 2 4 9 12 8 3 and if is different from any of these numbers it writes, if it should not, go to random.The error is that it is always recording whether it already exists or not.
buran write Feb-02-2021, 01:12 PM:
Please, use proper tags when post code, traceback, output, etc. This time I have added tags for you.
See BBcode help for more info.
Please, use proper tags when post code, traceback, output, etc. This time I have added tags for you.
See BBcode help for more info.