Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

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?