Percebi que, ao executar o código, os votos inválidos são contados também. Existe alguma forma de contornar esse problema com o que aprendemos até aqui neste curso? Segue o código:
votos_candidato1 = 0
votos_candidato2 = 0
votos_candidato3 = 0
votos_candidato4 = 0
votos_nulos = 0
votos_branco = 0
for i in range(0,20): # 20 funcionários votando
voto = int(input('Informe seu voto: '))
if voto == 1:
votos_candidato1 += 1
elif voto == 2:
votos_candidato2 += 1
elif voto == 3:
votos_candidato3 += 1
elif voto == 4:
votos_candidato4 += 1
elif voto == 5:
votos_nulos += 1
elif voto == 6:
votos_branco += 1
else:
print('Voto inválido.')
print(f'Votos candidato 1: {votos_candidato1}')
print(f'Votos candidato 2: {votos_candidato2}')
print(f'Votos candidato 3: {votos_candidato3}')
print(f'Votos candidato 4: {votos_candidato4}')
print(f'Votos nulos: {votos_nulos}')
print(f'Votos em branco: {votos_branco}')
print(f'Percentual de votos nulos: {(votos_nulos / 20 * 100)}')
print(f'Percentual de votos em branco: {(votos_branco / 20 * 100)}')