【发布时间】:2021-10-16 03:50:00
【问题描述】:
基本上,我的游戏运行 3 个字 - Steal、Deal 或 Quit 但是我想要一个选项,如果用户输入说字母 's' 它应该 = Steal 作为输出(玩家正在使用 PC 和结果游戏的数量基于 2 个值。
human = input('Steal, Deal or Quit [s|d|q]?:')
print(" ")
print('You chose: ' + human)
#Computer input
sd = ["Steal", "Deal"]
computer_choice = random.choice(sd)
print('Comp chose: ' + computer_choice)
print(" ")
if human == computer_choice:
print('Draw! Split pot -50 each')
elif human == 'Steal' and computer_choice == 'Deal':
print('You win! You gain 100.')
elif human == 'Deal' and computer_choice == 'Steal':
print('You loose! Comp gain 100.')
elif human == 'Steal' and computer_choice == 'Steal':
print('Too Greedy! You get nothing')
【问题讨论】:
-
为什么
quit没有代码? -
请在未来发送minimal reproducible example。 90% 的代码与问题无关。
-
那是我的错,我复制粘贴了两次,不是故意重复。我只是一步一步地完成它,退出代码是下一步!感谢您提供的最小可重现示例将在未来提供很好的帮助!