私はクリケットの試合のためのトスを得る方法を作成しました。私はあなたが投げるあなたがに引数として渡す変数にそれを割り当てるから結果をreturn
しなければならないファンクションの結果をデータとして使用するにはどうすればよいですか?
import random
tos = input("Choose head or tail \n")
def toss():
if tos == "head":
result = ["Bat", "Bowl"]
r =print(random.choice(result))
elif tos == "tail":
result = ["Bat", "Bowl"]
r =print(random.choice(result))
else:
print("ERROR!")
toss()
def result():
# i need the value in toss either bat or bowl to be used in if
if r =="Bat":
runs = ["1" , "2","3","4","5","6","7","8","9","0","W",]
runs_2=print(random.choice(runs))
result()
おかげで しかし、私はトスがバットであれば実行を表示する必要があるが、ここでは 'myToss'は' NONE'が、それは単に何かすることはできないためです –
をdoesntの。私の答えをチェックしてください。 – Unatiel