1
I made an algorithm in Python with the proposal to guess a number as the user type, ie the guessing game. But I would like to make a condition that makes him type again, in case he does not choose the desired number, I have no idea how I do, because of the module random
.
import random
import time
def c():
num =(int(input("Adivinha um numero de 0 a 5: ").strip()))
numB = random.randint(0,5)
print("CARREGANDO..............................")
time.sleep(1)
if num == numB:
print('Parabéns! Você acertou o numero\n'
'Você é um vencedor !')
elif num > numB: # Condição do valor diferente, só uma amostra(Está errado)
print("Valor errado")
else:
print("Errado! Tente de Novo")
time.sleep(1)
c()
c()
Did the answer solve your question? Do you think you can accept it? See [tour] if you don’t know how you do it. This would help a lot to indicate that the solution was useful for you. You can also vote on any question or answer you find useful on the entire site (when you have 15 points).
– Maniero