lundi 18 juillet 2016

I'm making a higher or lower game but one of the if statements is not being recognised, along with the input needed for it to function

So I'm making a higher or lower game within a program that is meant to be a casino-type program, I have set up a rock paper scissors program and it runs fine, however I cannot get this function to work

def HoL(player):   
      if playbalance > 0:
            global playbalance
            cpuchoice = random.randint(1,20)
            playerguesses = 0
            print("You have three guesses, and with them you have to guess the number that the computer guessed")
            print("the number is between and including 1 to 20")
            print("You hand over £100 to play")
            playbalance = playbalance - 100
            print("Let's play!")
            while playerguesses < 6:
                    playerguess = int(input("Take a guess"))
                    playerguesses = playerguesses + 1
                    if playerguess == cpuchoice:
                          print("You guessed it!")
                          break
                    elif playerguess > cpuchoice:
                          print("That's too high!")
                    elif playerguess < cpuchoice:
                          print("That's too low!")
                    elif playerguess == cpuchoice:
                          playerguesses = str(playerguesses)
                          print("Well done, you guessed the number in",playerguesses,"guesses!")
                          playbalance = playbalance + 200
                          secondchoice = input("Play again?")
                          secondchoice = secondchoice.lower()
                          if secondchoice == "yes":
                                playerguesses = 0
                          elif secondchoice != "yes":
                                print(secondchoice)
                                menu(player)
                    else:
                                menu(player)

The part of the code I am having trouble with is this:

                          secondchoice = input("Play again?")
                          secondchoice = secondchoice.lower()
                          if secondchoice == "yes":
                                playerguesses = 0
                          elif secondchoice != "yes":
                                print(secondchoice)
                                menu(player)
                    else:
                                menu(player)

Any help is greatly appreciated

Aucun commentaire:

Enregistrer un commentaire