Beginning guessing game in Python I've just finished work on my guessing game. I'm still fairly new to Python, so I'm looking for feedback and criticism on the code.

def game():

    import random #imports the module 'random'

    yes={"Yes","Y","yes","y"} #set 'yes' to these 4 strings
    no={"No","N","no","n"} #set 'no' to these 4 strings

    name=input("What is your name? \n") #asks for a name

    secret=int(random.random()*10)+1 #randomly generate a number

    trynum=0 #sets the number of tries to 0

    print ("---------------------------------------------------------------------\n"
           "---- Welcome,",name+"!\n"
           "---- I am thinking of a number between 1 and 10.\n"
           "---- Lets see how many times it will take you to guess the number.\n"
           "---------------------------------------------------------------------\n")

    while True: #starts a loop

        trynum=trynum+1 #sets number of tries to itself + 1

        guess=int(input("What is guess #"+str(trynum)+"? \n")) #asks for a guess

        if guess&lt;secret: #if guess is too low/less than(&lt;)
            print ("Too Low. Try again!")

        elif guess&gt;secret: #if guess is too high/greater than(&gt;)
            print ("Oops!! Too high, better luck next try!")

        else: 
            if trynum==1: #if number of tries is only 1
                print ("-------------------------------------------------\n"
                       "----",name+"! You got it in",trynum,"guess!\n"
                       "-------------------------------------------------\n")
            else: #if number of tries is anything else
                print ("-------------------------------------------------\n"
                       "----",name+"! You got it in",trynum,"guesses!\n"
                       "-------------------------------------------------\n")

            if trynum&lt;3: #if guessed in less than 3 tries
                print ("Bravo!")

            elif trynum&lt;5: #if guessed in less than 5 tries
                print ("Hmmmmpf... Better try again")

            elif trynum&lt;7: #if guessed in less than 7 tries
                print ("Better find something else to do!")

            else: #if guessed in more than 7 tries
                print ("You should be embarssed! My dog could pick better.")

                choice=input("""Would you like to play again? ("yes" or "no")\n""") #asks if you want to play again
                if choice in yes: #if yes, then run game again
                    game()
                if choice in no: #if no, then quit the game
                    print ("Okay.. Goodbye :(")
                    quit
            break
game()
Good job for a first experience in Python! You can improve your code a little by looking at these recommendations:


To choose a random integer, you could simply use random.randrange(0,11)
You should probably not import at the function level either, try writing your import statements at the top of your file.
The game() function is called recursively; you shouldn't do that. You could have an infinite loop that fires game() back when exited.
Personally, I wouldn't use lists with "yes" and "no" values, try something like

if "y" in choice.lower():
    return True 
else:
    return False

Last but not least, you should check if the number entered is an integer. If it is not, ask the user to enter a valid integer until they do so.