我创造了一种方法来获得板球比赛的折腾。我需要从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