我正在用python做一个文字冒险游戏,我随机地给我的每个第一选择( A,B,C)做了一个反应,现在让我说他在选择A时什么都找不到。
“如果没有发现,(* 在这里插入另一个选项列表, *)”
在我的密码里?我似乎找不到答案,所以我希望这里有人知道,谢谢!到目前为止,这是我的代码:
import time
import random
print ('You suddenly jolt up from the sleeping bag, awoken by the howling of nearby wolves.\nYou are cold, shivering and starving, and the few things that are still visible,\nare lit up only by the moon, and notice you are in the middle of a forest.\n')
ch1 = str(input(' Do you: \nA: Use your hands to search around\nB: Sleep again until morning\nC: Get up, and attempt to run away from the wolves in the dark:\n'))
responsesA = [
'You found a torch!',
'You did not find anything.'
]
responsesB = [
'You fell asleep again cold and hungry.',
'You are unable to sleep.'
]
responsesC = [
'You start running as fast as you can and successfuly escape!',
'You trip and injure knee.'
]
if ch1 in ['A']:
print (random.choice(responsesA))
if ch1 in ['B']:
print (random.choice(responsesB))
if ch1 in ['C']:
print (random.choice(responsesC))有什么我该换的吗?
发布于 2019-04-14 19:34:30
这个怎么样?
if ch1 in ['A']:
random_value = random.choice(responsesA)
print(random_value)
if random_value == 'You did not find anything.':
# insert another list of choices here与其打印出随机值,不如将其保存在变量中,然后检查随机值是否为“无值”,并相应地处理它。
https://stackoverflow.com/questions/55679225
复制相似问题