私はこの推測ゲームの最後にいくつかのコードを追加して、ユーザーに再試行するかどうか尋ねます。彼らが「はい」と答えた場合、プログラムは最初からやり直しています。私は複数のアイデアを試しましたが、誰も働いていません。最も近いものは、最後に別のifループでした。ありがとうございました! xこのPython Guessing Gameをもう一度やり直すにはどうしたらいいですか?
print("Welcome to this guessing game!")
import random
x = random.randrange(50)
guess = int(input("I've picked an integer between 1 to 99. Guess what it is: "))
while x != "guess":
print
if guess < x:
print("Your guess is too low!")
guess = int(input("Guess again:"))
elif guess > x:
print("Your guess is too high!")
guess = int(input("Guess again:"))
else:
print ("You guessed the right number!")
もう一つの 'while'ループを試してみてください。 – doctorlove
whileループを使用します。 しばらくkeepPlaying ==真){ を*彼らはプレーを続けるたい場合は何もその後、設定されている場合* をお願い致しkeepPlaying =偽 ) –
[推測ゲームのためのプログラムのバグ(の可能性のある重複http://stackoverflow.com/questions/39902412/bug-with-a-a-guessing-game) – doctorlove