Monday 15 September 2014

Restart option in Guess The Number in Python -


I think this number will guess the assignment. I do not like this right and I need some help. The game is not working again because when you win the game and choose yes to play again, it does not start the game again, it will be your next Continuing on the estimate number (example: estimate number 1, estimate number 2 ...). But when you lose, you go back to the first part where he "tries to" how much you want, how can I get that part where you live to do this? Besides, can someone give me some suggestions to improve signal suggestion? Also, do I need to include any def main (): stuff? Because I'm not sure that we've got this work so far at that point. Please help me please thank you

  # This is an estimate number game. Random answer = "yes" number = random. Import the renderer (1, 10) while the answer == 'yes': tries = 0 looks = 0 = 0 probes = 0 (int (input "how many Would you like to try? ") Tries2 = tries, while tries! = Tries2: Estimate number + = 1 estimate = int (input ("Enter estimate number" + str (guessnumber) + ":")) If the guess is & lt; Number: print ("you have a very low estimate") signal = input ("Would you like a signal, yes or no?:") If signal == "no": Continue the print ("number is low", number + 1) If Estimates & gt; Number: Print ("You have guessed too much") Hint = Input ("Would you like a hint, yes or no?:") If signal == "No": Continue to print ("Number Large Number", Number - 1) If looks == number: tries = string (tries) print ("you von!") Answer = input ("play again? Yes / no?") 'Enter code' Answer == 'No': Break if it seems! Answer = Input ("Play again? Yes / No?") If the answer == "No" = number: Number = Str (number) print ("Game over !!! !!! I was thinking that number" : Break    

Some Things:

Random (1, 1 ) The production of random integer between 1 and 1 is saying. It always gives 1.

Why is there a copy of "tries" when set only once?

Indentation in Python Matters changes that if / alif / other branches are evaluated. Given that (states & gt; numbers) and (Estimate == number) conditional on the check (seems & lt; numbers) is impossible, given that these states: (looks & lt; numbers), (Estimate & gt; Number) and (Estimate == number) are mutually exclusive and compare the same variable, the latter is best to replace.

"Game over" should probably trigger only after trying to trigger, so this (guessnumber & lt; tries) can not be inside the loop.

  # This is the guess number in the answer to the random answer = "yes" number = random. (1, 100) Answer! = 'No': looks = 0 = 0 = int (int (input ("how many effort do you want?")) Whereas the estimation number & lt; Tries: estimation number + = 1 estimate = int (input ("enter estimate number" + str (guessnumber) + ":")) If the guess is & lt; Number: print ("you have a very low estimate") signal = input ("Would you like a signal, yes or no?:") If signal == "no": Continue the print ("number is low", number + 1) Eleph Estimates & gt; Number: Print ("You have guessed too much") Hint = Input ("Would you like a hint, yes or no?:") If signal == "No": Continue Print ("Number is big number" , Number - 1) Alif estimation == Number: print ("You von!") Answer = Input ("Play again? Yes / No?") # Center codes break here if (looks! = Number) and ( Estimation number = = attempts): number = str (number) print ("Game Over !!! !!! I was thinking that Number "+ number) Answer = Input (" Play Again? Yes / No? ")    

No comments:

Post a Comment