【发布时间】:2021-02-25 16:02:07
【问题描述】:
所以我在制作 Rock,paper,Scissors 游戏,我的问题是在调用包含从列表“工具”中随机选择的字符串的变量后,我一直得到 None 值。
import random
tools =["Rock","Scissors","Paper"]
def computer_predicion():
computer_pred = random.choice(tools)
print(computer_predicion())
【问题讨论】:
-
函数中没有return语句
-
return computer_pred就是你要找的东西 -
下一个错误返回函数外
标签: python string list function random