Python不断循环而不要求输入

时间:2019-05-08 21:02:49

标签: python loops input

二十一点

如果我键入h,则代码将保持“击中”状态,而不是要求用户在击打一次后每次输入h / s击中/站立。当我运行此命令时,游戏会自动持续击打直至崩溃。

def hit_stand(library, hit): # libary = player, hit = input
     value = 0
     totalValue = 0
     count = 2
     d_score = 0
     p_turn =1
     while p_turn ==1:
         if hit == 'h':
             print(hitFun(library))
             value = value + player[count][2]
             totalValue = value + player[0][2] + player [1][2]
             if player[0][0] == "Ace" and totalValue <=11:
                 totalValue = totalValue+10
             elif player[1][0] == "Ace" and totalValue <=11:
                 totalValue = totalValue+10
             elif player[count][0] == "Ace" and totalValue <=11:
                 totalValue = totalValue+10
             else:
                 pass
             count = count + 1
             print(totalValue)
             if totalValue>21:
                 bust = "bust"
                 print(bust)
                 d_score = d_score+1
                 p_turn=0
                 return p_turn
             elif totalValue<22:

0 个答案:

没有答案