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!

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.

Start your free trial

Python Python Basics (2015) Number Game App Number Game Refinement

Ali Dahud
Ali Dahud
3,459 Points

is it alright the way I have done it?

import random



def play_game():

number_of_guesses = 1

while number_of_guesses<5:


        guess=int(input("Enter a guess between 1-10: "))

    except ValueError:

        print("A Number pllease!")


        if guess>secret_num:

            print("you entered too high!")

        if guess<secret_num:

            print("you entered too low!")

        if guess==secret_num:

            print("you guessed it right the number was: {}".format(secret_num))



answer = input("Enter Done if you're done playing: ")

if answer=="Done":

    print("Thank you for playing!")




AND WHAT'S the purpose of creating a game that loops until forever if we want it if we guessed the number already?