我創造了一種方法來獲得板球比賽的折騰。我需要從toss()
使用該結果在另一個溫控功能的結果()如何將函數的結果用作數據到另一個?
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',它根本就不能算是別的。檢查我的答案。 – Unatiel