diff --git a/Guess_number_1_to_10.py b/Guess_number_1_to_10.py new file mode 100644 index 00000000..32e14995 --- /dev/null +++ b/Guess_number_1_to_10.py @@ -0,0 +1,28 @@ +import random as rd + +num = rd.randint(1, 10) + +print("Try to answer the number in 3 tries or less:") +cont = 1 +while True: + try: + entry = int(input(f"Try {cont}: ")) + break + except: + print("Introduce only a number.\n") + +while entry != num and cont < 3: + cont += 1 + print(f"wrong answer, yo have {4 - cont} tries left.\n") + while True: + try: + entry = int(input(f"Try {cont}:")) + break + except: + print("Introduce only a number.\n") + +if entry == num: + print("\nCongratulatios, you win.") + +else: + print(f"\nYou Lose, the correct answer was {num}.") \ No newline at end of file