Guess the number GAME (Guess limit is 9) - You vs. Computer



import random
rNum = random.randint(1, 100)
i = 0
while i<10:
    gn = int(input("We have chosen a number between 1 and 100. Guess what? "))
    i+=1
    print("Total guess limit is 9")
    print(f"Guess number {i}")
    print("Total guesses left are", 9-i)
   
    if i==9:
        print("You exhausted your guess limit. Game over!")
        break

    if gn < rNum:
        print("Suggestion: Choose higer number")

    if gn > rNum:
        print("Suggestion: Choose lower number")
       
    if gn == rNum:
        print(f"You Won the game in {i} guesses!. Your number was {gn}")
        print(f"Our chosen number was {rNum}")
        break






Comments

Popular posts from this blog

Quotation marks to wrap an element in HTML

What is the difference between iostream and iostream.h in cpp?

The Basic Structure of a Full-Stack Web App