0
The first part that is to detect the position of the list I have already managed, the problem is at the time of Else, would like to know a method by which the Else is not printed together with the if.
Code and "database" below:
Code
def listar_critico():
arq = open("arquivo.csv", "r")
linhas = arq.readlines()
critico = input("Digite o nome do crítico que você deseja imprimir o registro..: ")
for linha in linhas:
campos = linha.split(";")
if critico in campos:
print("\nCrítico: %s\nEmail: %s" % (campos[2], campos[3]))
else:
print("%s não está registrado no banco de dados." % critico)
arq.close()
Database -> https://repl.it/Jbl1/5
It depends on the structure of your file. Will the record always be unique, when it exists? Or can there be a situation where there is more than one record for the same critic? If you are interested, Python has a native library to work with CSV files.
– Woss
The record will be unique always, just want to save the critics in some . csv even. I will read more about this library, but for now I want to do it in the same "primitive" way.
– Kenneth Anderson