シンプルなpython 2のコイン投げゲームです。わからないところ私が間違っているつもりですが、私は「あなたはそれを得た」印刷する正しい構文をコーディングすることはできません、ユーザーが正しく推測するとき....コイン投げゲームのPythonバグ
import random
guess = ''
while guess not in ('heads', 'tails'):
print('Guess the coin toss! Enter heads or tails:')
guess = input()
toss = random.randint(0, 1) # 0 is tails, 1 is heads
if toss == guess:
print('You got it!')
else:
print('Nope! Guess again!')
guess = input()
if toss == guess:
print('You got it!')
else:
print('Nope. You are really bad at this game.')
へ
'heads'
と'tails'
0
とし、1
の変化を比較しているあるかもしれない '1の場合です!= ' 1''? –
それは '1 '=' 1 'でさえありません。 '1!= 'heads''です。 –