0
I made a line of code to do a search on a street to find out which channel people watch, and I put it to compute the vote by channel number or channel name, but it only computes the votes made by number and not by name, can give me a light ?
def pesquisa_audiencia (canal):
global canal_cultura, canal_globo, canal_band, canal_record
if canal.isalpha():
if canal== 'Encerrar':
print('Encerrado')
print_resultados()
elif canal.isalnum():
if canal == '2' or canal == 'Cultura' or canal == '4' or canal == 'Globo' or canal == '7' or canal == 'Band' or canal == '9' or canal == 'Record':
if canal == '2':
canal_cultura +=1
elif canal == 'Cultura':
canal_cultura +=1
elif canal == '4':
canal_globo +=1
elif canal == 'Globo':
canal_globo +=1
elif canal == '7':
canal_band +=1
elif canal == 'Band':
canal_band +=1
elif canal == '9':
canal_record +=1
elif canal == 'Record':
canal_record +=1
def print_resultados():
global canal_cultura, canal_globo, canal_band, canal_record
print('Porcentagem de Audiência por canal:\n')
print('Canal 2:' + str(canal_cultura))
print('Canal 4:' + str(canal_globo))
print('Canal 7:' + str(canal_band))
print('Canal 9:' + str(canal_record))
exit()
if __name__ == '__main__':
canal_cultura = 0
canal_globo = 0
canal_band = 0
canal_record = 0
while True:
canal = input('Qual canal estão assistindo neste momento em sua casa?')
pesquisa_audiencia(canal)