0
Total hits and kicks do not appear correct, if I change "hits" and "totalguess" to 0 the first hit or kick counts as 0 and wanted as 1
from random import randint
acertos = 1
totalguess = 1
while acertos != 10:
x = randint(1, 5)
chute = int(input('Enter your guess'))
if chute == x:
print('Congratz! \n' + str(acertos) + ' Hits ')
totalguess += 1
acertos += 1
else:
print('Not quite! \nTry again! \n' + 'Attempts: ' + str(totalguess))
totalguess += 1
print('End Game!\n' + 'Hits:' + str(acertos) + '\nAttempts: ' + str(totalguess))
To solve the problem is not only initialize
acertos
andtotalguess
with0
and update the value (totalguess += 1
andacertos += 1
) before printing the messages?– AlexCiuffa
Thank you very much!
– Josias Boeno