【发布时间】:2015-01-08 04:39:18
【问题描述】:
我有两个列表:
wordlists1 = ["hot","summer", "hard", "dry", "heavy", "light", "weak", "male",
"sad", "win", "small","ignore", "buy", "succeed", "reject", "prevent", "exclude"]
wordlists2 = ["cold", "winter", "soft", "wet", "light", "darkness", "strong", "female", "happy", "lose", "big",
"pay attention", "sell", "fail", "accept", "allow", "include"]
我使用 random.choice 从每个列表中选择一个单词。一旦我有了单词,我需要将它们作为问题打印出来。例如,如果选择 hot 和 weak 它应该打印:“Hot is to cold as weak is to___?”
我真的需要这方面的帮助,我们将不胜感激。
我的代码:
import random
wordlists1 =["hot","summer", "hard", "dry", "heavy", "light", "weak", "male", "sad", "win", "small","ignore", "buy", "succeed", "reject", "prevent", "exclude"]
wordlists2 =["cold", "winter", "soft", "wet", "light", "darkness", "strong", "female", "happy", "lose", "big", "pay attention", "sell", "fail", "accept", "allow", "include"]
randomword1=random.choice(wordlists1)
randomword2=random.choice(wordlists2)
【问题讨论】:
-
向我们展示您目前拥有的代码,即使它已损坏。
标签: python