Python Project (Number Game)
Python Project (Number Game)
import random
attempts_list = []
def show_score():
if not attempts_list:
print('There is currently no high score,'
' it\'s yours for the taking!')
Python project Page 1
Number guessing game
else:
print(f'The current high score is'
f' {min(attempts_list)} attempts\U0001F600')
def start_game():
attempts = 0
rand_num = random.randint(1, 10)
print('\U0001F44B Hello traveler! Welcome to the game
of guesses!')
print("\r")
player_name = input('What is your name? ')
wanna_play = input(
f'\U0001F44B Hi, {player_name}, would you like to play
the guessing game? \n(Enter Yes/No): ')
if wanna_play.lower() != 'yes':
print("Ok , thank you° \U0001F642 ")
exit()
else:
show_score()
attempts += 1
attempts_list.append(attempts)
if guess == rand_num:
print("--------------------------------------------------")
print('\U0001F44F Nice! You got it!')
print(f'It took you {attempts} attempts')
print("------------------------------------------------")
wanna_play = input(
'Would you like to play again? (Enter Yes/No): ')
if wanna_play.lower() != 'yes':
print('\U0001F642 That\'s cool, have a good
one!')
break
else:
attempts = 0
rand_num = random.randint(1, 10)
show_score()
continue
else:
if guess > rand_num:
print('It\'s lower')
elif guess < rand_num:
print('It\'s higher')
if _name_ == '_main_':
start_game()