0
from random import randint
# Dados
lista_tentativas = list()
quantidade_tentativas = 0
# Entrada de dados
x = int(input('Informe um numero entre 0 e 10:'))
# Tentativas
while True:
y = randint(0,10)
quantidade_tentativas += 1
lista_tentativas.append(y)
if y == x:
print('O numero digitado foi {}')
print(f'Essas foram todas as minhas tentativas: {lista_tentativas}')
print(f'Essa foi a quantidade total de tentativas: {quantidade_tentativas} tentativas')
break
The way I am doing there is the possibility of trying the same number. I want to remove this possibility. But how?
As your answer already contemplates what the AP asks, I’ll just leave the tip that
lista_tentativas
be aset()
as it is an optimized data structure for cases like this. ;D– fernandosavio
@fernandosavio agree, but I am finding it more didactic to leave the code of the answer as close as possible to that of the question, to facilitate the understanding
– nosklo
It was not a change suggestion, the answer is good. I left the comment for people to read after reading your reply, as an addition. :)
– fernandosavio