我必须创建一个提供选项列表的游戏,您可以选择一个gand,它会根据您的选择给出随机项目。例如。从Python中的前一个选择中随机选择
fruit = apple, orange, grapefruit
berries = grape, raspberries, blackberries
vegetable = carrot, lettuce, broccoli
selection = raw_input("What is your selection? ")
import random
from random import choice
print choice(selection)
如果我说水果的话,水果的回应会随机发一封信。
你试过什么吗?你有什么具体的问题? – millimoose 2013-02-13 10:52:06
@MitchWheat:它下面的代码*是*尝试.. – 2013-02-13 10:52:18