我必須創建一個提供選項列表的遊戲,您可以選擇一個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