How to make number guessing game in Python = Nroup

How to make number guessing game in Python

project

This video :


This project code :  {:-)

import random
def game():
number = random.randint(1, 100)
tries = 1
done = False

while not done:
guess = int(input("Enter a guess: "))

if guess == number:
done = True
print(f"You are Won! : {number}")
else:
tries += 1
if guess > number:
print(f"The actual number is smaller!")
else:
print(f"The actual number is larger!")

print(f"You needed {tries} tries!")

game()

No comments

Theme images by luoman. Powered by Blogger.