-2
This function should ask for a name to be used as a search term. If the search movie is in the list, all data from the movie. Otherwise, a message that is not on the list.
This is the function I created to try to resolve the issue but it presents some flaws that I quote below:
def funçao2(n):
arq = open('ListaFilmes.txt', 'r')
conteudo = arq.readlines()
arq.close()
n = str(input('Digite o nome do filme: '))
for linha in conteudo:
linha = linha.split(';')
for coluna in linha:
coluna = coluna.split()
coluna1 = linha[0]
coluna2 = linha[1]
coluna3 = linha[2]
coluna4 = linha[3]
for elem in coluna:
if n == elem:
print('NOME:',coluna1)
print('GÊNERO:',coluna2)
print('CLASSIFICAÇÃO:',coluna3)
print('ANO DE LANÇAMENTO:',coluna4)
else:
print('O filme não consta na lista')
So that I created, if for example I want to access a film that is in the list, he accesses the movie, but also shows the message 'The movie is not in the list', message this is only to happen if I try to look for a movie that is not in the list, and when I go to look for a movie that is not on the list, this message appears several times.
You can help me to fix the code so that if I search for the film in the list, the program shows only the searched movie, and if I look for a movie that is not in the list, the program shows the message 'The movie is not in the list' only once?
Please do not duplicate your questions. If the previous question has been closed, edit it clarifying what was asked in the comments
– hkotsubo