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
Post a Comment
Write something to CodeWithAbdur!