私は基本的なゲームを2人の選手を1〜3のサイコロを選ぶことができます。ループを作成して終了できますか?
ロールをループして終了し、続行して、ロールするサイコロの数を選択して開始画面に移動する方法がわかりません。これのスコアを維持するために使用できるもの。これは私が持っているコードです。
コマンドがどのように私は
random
モジュールとrandint
機能を使用してオプションのすべて
Dice = input("Please select number of dice you would like to use (1-3)")
if Dice == "1":
print("You have selected 1 dice")
import random
Roll1 = random.randrange(1,6)
print ("Player 1's Roll")
print(Roll1)
print ("Player 2's Roll")
print (Roll1)
#2 Dice Counter
if Dice == "2":
print("You have selected 2 dice")
import random
Roll2 = (random.randrange(2,12))
print ("Player 1's Roll")
print(Roll2)
print ("Player 2's Roll")
print (Roll22)
#3 Dice Counter
if Dice == "3":
print("You have selected 3 dice")
import random
Roll3 = random.randrange(3,18)
print ("Player 1's Roll")
print(Roll3)
print ("Player 2's Roll")
print (Roll3)
while invalid_input :
Dice()
まず、:、今このメッセージを終了し、さよならするループ
while (inputValue != -1)
が終了し、乱数を生成するためのrandint
を使用し、チェック次のスニペットために印刷されますが発生しますユーザ入力-1
まで、ループ内getDiceInput()
を呼び出しておきますOPはすでにそれをやっています。次に、コードに構文エラーがあります。 – TigerhawkT3彼は 'randint'を使用しておらず、構文エラーはどこですか? –
彼らは非常に似通った 'randrange'を使用しています。これは、実際の質問のいずれの部分にも対処しません。 – TigerhawkT3