Skip to content

Update guess_number.py #1

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 11 additions & 9 deletions guess_number.py
Original file line number Diff line number Diff line change
@@ -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()
# Main function call
guess_the_number()