Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions Guess_number_1_to_10.py
Original file line number Diff line number Diff line change
@@ -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}.")