Python
Python
# We assign a variable "Chances" that will act as the counter for a loop
# The user will have to input his guess so we assign his guess into a variable.
chances = 0
while chances < 8:
chances += 1
guess = int(input("Enter your guess: "))
if random_number == guess:
print("Congragulations, you did it. The number was ", random_number)
break
elif guess < random_number:
print("You guessed a small number.")
elif guess > random_number:
print("You guessed a large number.")
if chances == 7:
print("\n You've run out of chances")
print("\n The number was ", random_number)
print("Better luck next time")
break
print("\n")
break