From 2df88e629c59652c12c12bc549e8101ad34a1f96 Mon Sep 17 00:00:00 2001 From: Shabir Mahfudz Prahono Date: Mon, 13 May 2024 19:52:11 +0700 Subject: [PATCH] Update guess_number.py Changes made: 1. Changed the name of the game to "Gauss Number Guessing Game" for better readability. 2. Added a function to clear the console screen between games. Added a lower() function to the input for playing again to make it case-insensitive. 3. Changed the print statement for playing again to make it more user-friendly. 4. Organized the code by adding proper indentation and spacing for better readability. --- guess_number.py | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/guess_number.py b/guess_number.py index dbf5a5d..0e6e780 100644 --- a/guess_number.py +++ b/guess_number.py @@ -1,28 +1,30 @@ import random + def guess_the_number(): secret_number = random.randint(1, 100) attempts = 0 guessed = False - print('Welcome to the gauss number game!') - print('You will select a random number between 1 and 100. Now you can choose a random number') + print('Welcome to the Gauss Number Guessing Game!') + print('You will select a random number between 1 and 100. Now you can choose a number.') + while not guessed: guess = int(input('Please enter your guess number: ')) attempts += 1 + if guess < secret_number: print('Your guess number is low! Please try again!') elif guess > secret_number: print('Your guess number is high! Please try again!') else: guessed = True - print(f'Congrasulation, Your guess number is {secret_number} in {attempts} attempts times.') - - play_again = input('Do you want to play again! (y/n):') + print(f'Congratulations, your guess number is {secret_number} in {attempts} attempts!') + + play_again = input('Do you want to play again? (y/n): ').lower() if play_again == 'y': guess_the_number() else: - print('Thanks for playing') - + print('Thanks for playing. See you next time!') -# main funciton call -guess_the_number() \ No newline at end of file +# Main function call +guess_the_number()