## Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

### Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

# Python Project 1 (trying to figure out how to restart program)

I got everything else to work but I just can't seem to think of how to restart the program. I tried looking through the forums and other submissions on GitHub but everyone either did different levels of features to the program. Since it's part of the definition for the start_game function, is it possible or do I need to remove it from the definition? I'm just not sure because the instruction told me to keep everything in the definition of start game. It's towards the bottom in a while block (line 59).

Thank you!

```import random
from statistics import mode, median, mean

def start_game():
print("Welcome to Team Treehouse's first project: Number Guessing Game!")

actual_guesses = []
high_score = []

while True:
try:
confirm_game = input("Are you sure you want to give it a shot? Y/N: > ")
if confirm_game.lower() == 'n':
print("Sorry to hear that, have a nice day!")
exit()
if confirm_game.lower() == 'y':
if len(high_score) < 1:
print("There is no current high score!")
else:
print("The current high score is {} attempts!".format(min(high_score)))
print("Pick a number between 1 and 100!")
break
else:
raise ValueError()
except ValueError:
print("That's not a valid selection. Please enter either Y or N.")
continue

while True:
try:
player_guess = int(input("> "))
if player_guess <= 0 or player_guess > 100:
raise ValueError()
except ValueError:
print("That's not a valid guess. Please only use whole numbers between 1 and 100.")
continue

print("It's lower!")
actual_guesses.append(player_guess)
continue
print("It's higher!")
actual_guesses.append(player_guess)
continue
else:
print("You got it right in only {} attempts!".format(len(actual_guesses)))
high_score.append(len(actual_guesses))
break

while True:
try:
restart = input ("How about another round? Y/N: > ")
if restart.lower() == 'y':
print("Coming right up!")
#how do I restart the game?
if restart.lower() == 'n':
print("""
Sorry to hear that. Here's your stats for this round!

Attempts: {}
Mean Guess: {}
Median Guess: {}
Mode Guess: {}

Come back later if you ever want to try again!
""".format(total_guesses, round(mean(actual_guesses)), round(median(actual_guesses)), round(mode(actual_guesses))))
exit()
else:
raise ValueError()
except ValueError:
print("Sorry that's not a valid selection. Please enter either Y or N.")

start_game()
```