是或否结束循环不显示

时间:2019-01-30 02:16:55

标签: python python-3.x

在我的代码中,我有一个“你想再玩一次”功能。由于某种原因,当我放置no时,它将在停止代码之前通过not yes或no循环运行。为什么这样做呢?这是我的代码:

  again = input('Would you like to play again?\t')
  while again != ('yes') or ('no'):
    print ('Error code 1: Please try again!')
    again = input('Would you like to play again?\t')
    if again == ('yes') or ('no'):
      break
  if again == ('no'):
    break

这是我的输出:

Would you like to play again?   no
Error code 1: Please try again!
Would you like to play again?   no

0 个答案:

没有答案