Manishkumarsingh41 / project

2 stars 0 forks source link

Guess The Number #2

Open Manishkumarsingh41 opened 8 months ago

Manishkumarsingh41 commented 8 months ago

This is a guess the number game.

import random secretNumber = random.randint(1, 30) print('I am thinking of a number between 1 and 30.')

Ask the player to guess 5 times.

for guessesTaken in range(1, 6): print('Take a guess.') guess = int(input()) if guess < secretNumber: print('Your guess is too low.') elif guess > secretNumber: print('Your guess is too high.') else: break # This condition is the correct guess! if guess == secretNumber: print('CONGRATULATION! You guessed my number in ' + str(guessesTaken) + ' guesses!') else: print(' The number I was thinking of was ' + str(secretNumber))

This is a guess the number game.

import random secretNumber = random.randint(1, 30)

Manishkumarsingh41 commented 8 months ago

This is a simple number guessing game. The game generates a random number between 1 and 30 and the player has 5 attempts to guess the number. The game provides feedback to the player if their guess is too high or too low. If the player guesses the correct number within 5 attempts, the game congratulates the player and displays the number of guesses taken. If the player does not guess the correct number within 5 attempts, the game reveals the correct number.