让我们想象一下我有:
question_list = ['how old are you?', 'how tall are you']
possible_answers = ['15, 14, 19, 32', '1.92cm, 2.01cm, 1.59cm, 1.72cm']
我希望能够将“你多大了?”与“15、14、19、32”相对应,所以当我随机打印问题列表中的一个问题时,我会从可能的答案中得到相应的答案。我该怎么做
我被困在这里的背景:
if random.choice(game_list) == 'trivia':
question = print(random.choice(question_list))
本质上,我想把一个列表中的某个东西和另一个列表中的另一个东西对应起来
使用
zip
将它们压缩在一起:如果要将答案作为列表,请使用逗号拆分:
您的标题方向错误,因为
print()
没有返回任何内容,您需要使用一个变量来存储索引,因为它必须使用两次相关问题 更多 >
编程相关推荐