-1
私はこれを作って動作させていますが、ちょっと厄介なので、100%動作させたいと思っています。これは、コード変数を取得してからPythonで空白のない文字列を入力する
import random
input_1 = str(input("Do you want to roll a dice? Enter y for yes anything else for no. "))
if input_1 == "y":
dicesides = int(input("How many sides do you want your dice to have? "))
diceroll = random.randint(1, dicesides)
print("The dice rolled a",diceroll ".")
input_2 = str(input("Do you want to roll the dice again? Same keys. "))
while input_2 == "y":
print(random.randint(1, dicesides))
input_2 = str(input("Do you want to roll the dice again? Same keys. "))
else:
print("Okay, goodbye now.")
else:
print("Okay, goodbye now.")
コードは、それは私に、それは「ロール」番号を伝える実行しますが、それは数の後にスペースを入れています。私はこの振る舞いを望まない。 2番目の+ダイスロールをどのように変更するかを知りました。
ありがとう!
'プリントを(、diceroll「サイコロはロール」「」)'無効な構文です。私はあなたが 'print("サイコロは{}を巻いた。 ")書式(diceroll)' ' –