0
I’m having a little problem with a list.
I have a txt with some information (log failure of a system) and wanted python to print for me this flaw with their "translation" example:
If cod_error == '1': print('Password invalidates')
and so on... follow the code:
# -*- coding: utf-8 -*-
row = []
li = []
x = 0
y = 0
count = []
with open("Txts/test3.txt", "r") as arq:
for linha in arq:
if linha.find('Failed') > -1:
li += linha.split(': ') #li recebe todos os valores separados pelo split ou seja li vai ter o valor anterior + o novo valor gerando assim uma lista conforme o numero de palavras que tem no texto
li = [item.replace("\n", "") for item in li]
y = len(li)
#print(li[x]) #colocar [x] x = numero para printar o valor especifico
while x != y :
#print('oi') #teste pra ver se ia executar a quanitdade de vezes correta
print(li[x]) #Teste pra ver se iria printar os valores alocados
if li[x] == '1':
print('Apenas um teste')
break
x = x + 1
my problem is that Python does not seem to be entering the IF condition (if I print a li[1] the value will be '1' but if does not work with these values)
BUT ALL WAY AND BETWEEN SO MUCH: if I put so if li[x] ='Failure' it enters the condition.....
@@EDIT: If does not work when the error returned is a number, if it is a letter it works normally
Can you put an excerpt from the log file? I believe this code can be greatly improved. By the way, what appears on the screen due to
print(li[x])
?– Woss